1 // SPDX-License-Identifier: GPL-2.0-only
3 * Huawei HiNIC PCI Express Linux driver
4 * Copyright(c) 2017 Huawei Technologies Co., Ltd
7 #include <linux/types.h>
8 #include <linux/netdevice.h>
9 #include <linux/etherdevice.h>
10 #include <linux/if_vlan.h>
11 #include <linux/pci.h>
12 #include <linux/device.h>
13 #include <linux/errno.h>
15 #include "hinic_hw_if.h"
16 #include "hinic_hw_dev.h"
17 #include "hinic_port.h"
18 #include "hinic_dev.h"
26 * change_mac - change(add or delete) mac address
27 * @nic_dev: nic device
29 * @vlan_id: vlan number to set with the mac
30 * @op: add or delete the mac
32 * Return 0 - Success, negative - Failure
34 static int change_mac(struct hinic_dev *nic_dev, const u8 *addr,
35 u16 vlan_id, enum mac_op op)
37 struct hinic_hwdev *hwdev = nic_dev->hwdev;
38 struct hinic_port_mac_cmd port_mac_cmd;
39 struct hinic_hwif *hwif = hwdev->hwif;
40 u16 out_size = sizeof(port_mac_cmd);
41 struct pci_dev *pdev = hwif->pdev;
42 enum hinic_port_cmd cmd;
46 cmd = HINIC_PORT_CMD_SET_MAC;
48 cmd = HINIC_PORT_CMD_DEL_MAC;
50 port_mac_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
51 port_mac_cmd.vlan_id = vlan_id;
52 memcpy(port_mac_cmd.mac, addr, ETH_ALEN);
54 err = hinic_port_msg_cmd(hwdev, cmd, &port_mac_cmd,
56 &port_mac_cmd, &out_size);
57 if (err || out_size != sizeof(port_mac_cmd) ||
58 (port_mac_cmd.status &&
59 (port_mac_cmd.status != HINIC_PF_SET_VF_ALREADY || !HINIC_IS_VF(hwif)) &&
60 port_mac_cmd.status != HINIC_MGMT_STATUS_EXIST)) {
61 dev_err(&pdev->dev, "Failed to change MAC, err: %d, status: 0x%x, out size: 0x%x\n",
62 err, port_mac_cmd.status, out_size);
66 if (port_mac_cmd.status == HINIC_PF_SET_VF_ALREADY) {
67 dev_warn(&pdev->dev, "PF has already set VF mac, ignore %s operation\n",
68 (op == MAC_SET) ? "set" : "del");
69 return HINIC_PF_SET_VF_ALREADY;
72 if (cmd == HINIC_PORT_CMD_SET_MAC && port_mac_cmd.status ==
73 HINIC_MGMT_STATUS_EXIST)
74 dev_warn(&pdev->dev, "MAC is repeated, ignore set operation\n");
80 * hinic_port_add_mac - add mac address
81 * @nic_dev: nic device
83 * @vlan_id: vlan number to set with the mac
85 * Return 0 - Success, negative - Failure
87 int hinic_port_add_mac(struct hinic_dev *nic_dev,
88 const u8 *addr, u16 vlan_id)
90 return change_mac(nic_dev, addr, vlan_id, MAC_SET);
94 * hinic_port_del_mac - remove mac address
95 * @nic_dev: nic device
97 * @vlan_id: vlan number that is connected to the mac
99 * Return 0 - Success, negative - Failure
101 int hinic_port_del_mac(struct hinic_dev *nic_dev, const u8 *addr,
104 return change_mac(nic_dev, addr, vlan_id, MAC_DEL);
108 * hinic_port_get_mac - get the mac address of the nic device
109 * @nic_dev: nic device
110 * @addr: returned mac address
112 * Return 0 - Success, negative - Failure
114 int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr)
116 struct hinic_hwdev *hwdev = nic_dev->hwdev;
117 struct hinic_port_mac_cmd port_mac_cmd;
118 struct hinic_hwif *hwif = hwdev->hwif;
119 u16 out_size = sizeof(port_mac_cmd);
120 struct pci_dev *pdev = hwif->pdev;
123 port_mac_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
125 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_MAC,
126 &port_mac_cmd, sizeof(port_mac_cmd),
127 &port_mac_cmd, &out_size);
128 if (err || out_size != sizeof(port_mac_cmd) || port_mac_cmd.status) {
129 dev_err(&pdev->dev, "Failed to get mac, err: %d, status: 0x%x, out size: 0x%x\n",
130 err, port_mac_cmd.status, out_size);
134 memcpy(addr, port_mac_cmd.mac, ETH_ALEN);
139 * hinic_port_set_mtu - set mtu
140 * @nic_dev: nic device
143 * Return 0 - Success, negative - Failure
145 int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu)
147 struct hinic_hwdev *hwdev = nic_dev->hwdev;
148 struct hinic_port_mtu_cmd port_mtu_cmd;
149 struct hinic_hwif *hwif = hwdev->hwif;
150 u16 out_size = sizeof(port_mtu_cmd);
151 struct pci_dev *pdev = hwif->pdev;
154 port_mtu_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
155 port_mtu_cmd.mtu = new_mtu;
157 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_CHANGE_MTU,
158 &port_mtu_cmd, sizeof(port_mtu_cmd),
159 &port_mtu_cmd, &out_size);
160 if (err || out_size != sizeof(port_mtu_cmd) || port_mtu_cmd.status) {
161 dev_err(&pdev->dev, "Failed to set mtu, err: %d, status: 0x%x, out size: 0x%x\n",
162 err, port_mtu_cmd.status, out_size);
170 * hinic_port_add_vlan - add vlan to the nic device
171 * @nic_dev: nic device
172 * @vlan_id: the vlan number to add
174 * Return 0 - Success, negative - Failure
176 int hinic_port_add_vlan(struct hinic_dev *nic_dev, u16 vlan_id)
178 struct hinic_hwdev *hwdev = nic_dev->hwdev;
179 struct hinic_port_vlan_cmd port_vlan_cmd;
181 port_vlan_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
182 port_vlan_cmd.vlan_id = vlan_id;
184 return hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_ADD_VLAN,
185 &port_vlan_cmd, sizeof(port_vlan_cmd),
190 * hinic_port_del_vlan - delete vlan from the nic device
191 * @nic_dev: nic device
192 * @vlan_id: the vlan number to delete
194 * Return 0 - Success, negative - Failure
196 int hinic_port_del_vlan(struct hinic_dev *nic_dev, u16 vlan_id)
198 struct hinic_hwdev *hwdev = nic_dev->hwdev;
199 struct hinic_port_vlan_cmd port_vlan_cmd;
201 port_vlan_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
202 port_vlan_cmd.vlan_id = vlan_id;
204 return hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_DEL_VLAN,
205 &port_vlan_cmd, sizeof(port_vlan_cmd),
210 * hinic_port_set_rx_mode - set rx mode in the nic device
211 * @nic_dev: nic device
212 * @rx_mode: the rx mode to set
214 * Return 0 - Success, negative - Failure
216 int hinic_port_set_rx_mode(struct hinic_dev *nic_dev, u32 rx_mode)
218 struct hinic_hwdev *hwdev = nic_dev->hwdev;
219 struct hinic_port_rx_mode_cmd rx_mode_cmd;
221 rx_mode_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
222 rx_mode_cmd.rx_mode = rx_mode;
224 return hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_MODE,
225 &rx_mode_cmd, sizeof(rx_mode_cmd),
230 * hinic_port_link_state - get the link state
231 * @nic_dev: nic device
232 * @link_state: the returned link state
234 * Return 0 - Success, negative - Failure
236 int hinic_port_link_state(struct hinic_dev *nic_dev,
237 enum hinic_port_link_state *link_state)
239 struct hinic_hwdev *hwdev = nic_dev->hwdev;
240 struct hinic_hwif *hwif = hwdev->hwif;
241 struct hinic_port_link_cmd link_cmd;
242 struct pci_dev *pdev = hwif->pdev;
243 u16 out_size = sizeof(link_cmd);
246 link_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
248 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_LINK_STATE,
249 &link_cmd, sizeof(link_cmd),
250 &link_cmd, &out_size);
251 if (err || out_size != sizeof(link_cmd) || link_cmd.status) {
252 dev_err(&pdev->dev, "Failed to get link state, err: %d, status: 0x%x, out size: 0x%x\n",
253 err, link_cmd.status, out_size);
257 *link_state = link_cmd.state;
262 * hinic_port_set_state - set port state
263 * @nic_dev: nic device
264 * @state: the state to set
266 * Return 0 - Success, negative - Failure
268 int hinic_port_set_state(struct hinic_dev *nic_dev, enum hinic_port_state state)
270 struct hinic_hwdev *hwdev = nic_dev->hwdev;
271 struct hinic_port_state_cmd port_state;
272 struct hinic_hwif *hwif = hwdev->hwif;
273 struct pci_dev *pdev = hwif->pdev;
274 u16 out_size = sizeof(port_state);
277 if (HINIC_IS_VF(hwdev->hwif))
280 port_state.state = state;
282 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PORT_STATE,
283 &port_state, sizeof(port_state),
284 &port_state, &out_size);
285 if (err || out_size != sizeof(port_state) || port_state.status) {
286 dev_err(&pdev->dev, "Failed to set port state, err: %d, status: 0x%x, out size: 0x%x\n",
287 err, port_state.status, out_size);
295 * hinic_port_set_func_state- set func device state
296 * @nic_dev: nic device
297 * @state: the state to set
299 * Return 0 - Success, negative - Failure
301 int hinic_port_set_func_state(struct hinic_dev *nic_dev,
302 enum hinic_func_port_state state)
304 struct hinic_port_func_state_cmd func_state;
305 struct hinic_hwdev *hwdev = nic_dev->hwdev;
306 struct hinic_hwif *hwif = hwdev->hwif;
307 struct pci_dev *pdev = hwif->pdev;
308 u16 out_size = sizeof(func_state);
311 func_state.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
312 func_state.state = state;
314 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_FUNC_STATE,
315 &func_state, sizeof(func_state),
316 &func_state, &out_size);
317 if (err || out_size != sizeof(func_state) || func_state.status) {
318 dev_err(&pdev->dev, "Failed to set port func state, err: %d, status: 0x%x, out size: 0x%x\n",
319 err, func_state.status, out_size);
327 * hinic_port_get_cap - get port capabilities
328 * @nic_dev: nic device
329 * @port_cap: returned port capabilities
331 * Return 0 - Success, negative - Failure
333 int hinic_port_get_cap(struct hinic_dev *nic_dev,
334 struct hinic_port_cap *port_cap)
336 struct hinic_hwdev *hwdev = nic_dev->hwdev;
337 struct hinic_hwif *hwif = hwdev->hwif;
338 struct pci_dev *pdev = hwif->pdev;
339 u16 out_size = sizeof(*port_cap);
342 port_cap->func_idx = HINIC_HWIF_FUNC_IDX(hwif);
344 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_CAP,
345 port_cap, sizeof(*port_cap),
346 port_cap, &out_size);
347 if (err || out_size != sizeof(*port_cap) || port_cap->status) {
349 "Failed to get port capabilities, err: %d, status: 0x%x, out size: 0x%x\n",
350 err, port_cap->status, out_size);
358 * hinic_port_set_tso - set port tso configuration
359 * @nic_dev: nic device
360 * @state: the tso state to set
362 * Return 0 - Success, negative - Failure
364 int hinic_port_set_tso(struct hinic_dev *nic_dev, enum hinic_tso_state state)
366 struct hinic_hwdev *hwdev = nic_dev->hwdev;
367 struct hinic_hwif *hwif = hwdev->hwif;
368 struct hinic_tso_config tso_cfg = {0};
369 struct pci_dev *pdev = hwif->pdev;
370 u16 out_size = sizeof(tso_cfg);
373 tso_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
374 tso_cfg.tso_en = state;
376 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_TSO,
377 &tso_cfg, sizeof(tso_cfg),
378 &tso_cfg, &out_size);
379 if (err || out_size != sizeof(tso_cfg) || tso_cfg.status) {
381 "Failed to set port tso, err: %d, status: 0x%x, out size: 0x%x\n",
382 err, tso_cfg.status, out_size);
389 int hinic_set_rx_csum_offload(struct hinic_dev *nic_dev, u32 en)
391 struct hinic_checksum_offload rx_csum_cfg = {0};
392 struct hinic_hwdev *hwdev = nic_dev->hwdev;
393 u16 out_size = sizeof(rx_csum_cfg);
394 struct hinic_hwif *hwif;
395 struct pci_dev *pdev;
403 rx_csum_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
404 rx_csum_cfg.rx_csum_offload = en;
406 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_CSUM,
407 &rx_csum_cfg, sizeof(rx_csum_cfg),
408 &rx_csum_cfg, &out_size);
409 if (err || !out_size || rx_csum_cfg.status) {
411 "Failed to set rx csum offload, err: %d, status: 0x%x, out size: 0x%x\n",
412 err, rx_csum_cfg.status, out_size);
419 int hinic_set_rx_vlan_offload(struct hinic_dev *nic_dev, u8 en)
421 struct hinic_hwdev *hwdev = nic_dev->hwdev;
422 struct hinic_vlan_cfg vlan_cfg;
423 struct hinic_hwif *hwif;
424 struct pci_dev *pdev;
431 out_size = sizeof(vlan_cfg);
434 vlan_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
435 vlan_cfg.vlan_rx_offload = en;
437 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RX_VLAN_OFFLOAD,
438 &vlan_cfg, sizeof(vlan_cfg),
439 &vlan_cfg, &out_size);
440 if (err || !out_size || vlan_cfg.status) {
442 "Failed to set rx vlan offload, err: %d, status: 0x%x, out size: 0x%x\n",
443 err, vlan_cfg.status, out_size);
450 int hinic_set_vlan_fliter(struct hinic_dev *nic_dev, u32 en)
452 struct hinic_hwdev *hwdev = nic_dev->hwdev;
453 struct hinic_hwif *hwif = hwdev->hwif;
454 struct pci_dev *pdev = hwif->pdev;
455 struct hinic_vlan_filter vlan_filter;
456 u16 out_size = sizeof(vlan_filter);
462 vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
463 vlan_filter.enable = en;
465 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_VLAN_FILTER,
466 &vlan_filter, sizeof(vlan_filter),
467 &vlan_filter, &out_size);
468 if (vlan_filter.status == HINIC_MGMT_CMD_UNSUPPORTED) {
469 err = HINIC_MGMT_CMD_UNSUPPORTED;
470 } else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
472 err = HINIC_MGMT_CMD_UNSUPPORTED;
473 } else if (err || !out_size || vlan_filter.status) {
475 "Failed to set vlan fliter, err: %d, status: 0x%x, out size: 0x%x\n",
476 err, vlan_filter.status, out_size);
483 int hinic_set_max_qnum(struct hinic_dev *nic_dev, u8 num_rqs)
485 struct hinic_hwdev *hwdev = nic_dev->hwdev;
486 struct hinic_hwif *hwif = hwdev->hwif;
487 struct hinic_rq_num rq_num = { 0 };
488 struct pci_dev *pdev = hwif->pdev;
489 u16 out_size = sizeof(rq_num);
492 rq_num.func_id = HINIC_HWIF_FUNC_IDX(hwif);
493 rq_num.num_rqs = num_rqs;
494 rq_num.rq_depth = ilog2(nic_dev->rq_depth);
496 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RQ_IQ_MAP,
497 &rq_num, sizeof(rq_num),
499 if (err || !out_size || rq_num.status) {
501 "Failed to set rxq number, err: %d, status: 0x%x, out size: 0x%x\n",
502 err, rq_num.status, out_size);
509 static int hinic_set_rx_lro(struct hinic_dev *nic_dev, u8 ipv4_en, u8 ipv6_en,
512 struct hinic_hwdev *hwdev = nic_dev->hwdev;
513 struct hinic_lro_config lro_cfg = { 0 };
514 struct hinic_hwif *hwif = hwdev->hwif;
515 struct pci_dev *pdev = hwif->pdev;
516 u16 out_size = sizeof(lro_cfg);
519 lro_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
520 lro_cfg.lro_ipv4_en = ipv4_en;
521 lro_cfg.lro_ipv6_en = ipv6_en;
522 lro_cfg.lro_max_wqe_num = max_wqe_num;
524 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO,
525 &lro_cfg, sizeof(lro_cfg),
526 &lro_cfg, &out_size);
527 if (err || !out_size || lro_cfg.status) {
529 "Failed to set lro offload, err: %d, status: 0x%x, out size: 0x%x\n",
530 err, lro_cfg.status, out_size);
537 static int hinic_set_rx_lro_timer(struct hinic_dev *nic_dev, u32 timer_value)
539 struct hinic_hwdev *hwdev = nic_dev->hwdev;
540 struct hinic_lro_timer lro_timer = { 0 };
541 struct hinic_hwif *hwif = hwdev->hwif;
542 struct pci_dev *pdev = hwif->pdev;
543 u16 out_size = sizeof(lro_timer);
546 lro_timer.status = 0;
548 lro_timer.enable = 1;
549 lro_timer.timer = timer_value;
551 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO_TIMER,
552 &lro_timer, sizeof(lro_timer),
553 &lro_timer, &out_size);
554 if (lro_timer.status == 0xFF) {
555 /* For this case, we think status (0xFF) is OK */
556 lro_timer.status = 0;
558 "Set lro timer not supported by the current FW version, it will be 1ms default\n");
561 if (err || !out_size || lro_timer.status) {
563 "Failed to set lro timer, err: %d, status: 0x%x, out size: 0x%x\n",
564 err, lro_timer.status, out_size);
572 int hinic_set_rx_lro_state(struct hinic_dev *nic_dev, u8 lro_en,
573 u32 lro_timer, u32 wqe_num)
575 struct hinic_hwdev *hwdev = nic_dev->hwdev;
583 ipv4_en = lro_en ? 1 : 0;
584 ipv6_en = lro_en ? 1 : 0;
586 err = hinic_set_rx_lro(nic_dev, ipv4_en, ipv6_en, (u8)wqe_num);
590 if (HINIC_IS_VF(nic_dev->hwdev->hwif))
593 err = hinic_set_rx_lro_timer(nic_dev, lro_timer);
600 int hinic_rss_set_indir_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx,
601 const u32 *indir_table)
603 struct hinic_rss_indirect_tbl *indir_tbl;
604 struct hinic_func_to_io *func_to_io;
605 struct hinic_cmdq_buf cmd_buf;
606 struct hinic_hwdev *hwdev;
607 struct hinic_hwif *hwif;
608 struct pci_dev *pdev;
614 hwdev = nic_dev->hwdev;
615 func_to_io = &hwdev->func_to_io;
619 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
621 dev_err(&pdev->dev, "Failed to allocate cmdq buf\n");
625 cmd_buf.size = sizeof(*indir_tbl);
627 indir_tbl = cmd_buf.buf;
628 indir_tbl->group_index = cpu_to_be32(tmpl_idx);
630 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) {
631 indir_tbl->entry[i] = indir_table[i];
633 if (0x3 == (i & 0x3)) {
634 temp = (u32 *)&indir_tbl->entry[i - 3];
635 *temp = cpu_to_be32(*temp);
639 /* cfg the rss indirect table by command queue */
640 indir_size = HINIC_RSS_INDIR_SIZE / 2;
641 indir_tbl->offset = 0;
642 indir_tbl->size = cpu_to_be32(indir_size);
644 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC,
645 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
646 &cmd_buf, &out_param);
647 if (err || out_param != 0) {
648 dev_err(&pdev->dev, "Failed to set rss indir table\n");
653 indir_tbl->offset = cpu_to_be32(indir_size);
654 indir_tbl->size = cpu_to_be32(indir_size);
655 memcpy(&indir_tbl->entry[0], &indir_tbl->entry[indir_size], indir_size);
657 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC,
658 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
659 &cmd_buf, &out_param);
660 if (err || out_param != 0) {
661 dev_err(&pdev->dev, "Failed to set rss indir table\n");
666 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
671 int hinic_rss_get_indir_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx,
674 struct hinic_rss_indir_table rss_cfg = { 0 };
675 struct hinic_hwdev *hwdev = nic_dev->hwdev;
676 struct hinic_hwif *hwif = hwdev->hwif;
677 struct pci_dev *pdev = hwif->pdev;
678 u16 out_size = sizeof(rss_cfg);
681 rss_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
682 rss_cfg.template_id = tmpl_idx;
684 err = hinic_port_msg_cmd(hwdev,
685 HINIC_PORT_CMD_GET_RSS_TEMPLATE_INDIR_TBL,
686 &rss_cfg, sizeof(rss_cfg), &rss_cfg,
688 if (err || !out_size || rss_cfg.status) {
689 dev_err(&pdev->dev, "Failed to get indir table, err: %d, status: 0x%x, out size: 0x%x\n",
690 err, rss_cfg.status, out_size);
694 hinic_be32_to_cpu(rss_cfg.indir, HINIC_RSS_INDIR_SIZE);
695 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++)
696 indir_table[i] = rss_cfg.indir[i];
701 int hinic_set_rss_type(struct hinic_dev *nic_dev, u32 tmpl_idx,
702 struct hinic_rss_type rss_type)
704 struct hinic_rss_context_tbl *ctx_tbl;
705 struct hinic_func_to_io *func_to_io;
706 struct hinic_cmdq_buf cmd_buf;
707 struct hinic_hwdev *hwdev;
708 struct hinic_hwif *hwif;
709 struct pci_dev *pdev;
714 hwdev = nic_dev->hwdev;
715 func_to_io = &hwdev->func_to_io;
719 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
721 dev_err(&pdev->dev, "Failed to allocate cmd buf\n");
725 ctx |= HINIC_RSS_TYPE_SET(1, VALID) |
726 HINIC_RSS_TYPE_SET(rss_type.ipv4, IPV4) |
727 HINIC_RSS_TYPE_SET(rss_type.ipv6, IPV6) |
728 HINIC_RSS_TYPE_SET(rss_type.ipv6_ext, IPV6_EXT) |
729 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv4, TCP_IPV4) |
730 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6, TCP_IPV6) |
731 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6_ext, TCP_IPV6_EXT) |
732 HINIC_RSS_TYPE_SET(rss_type.udp_ipv4, UDP_IPV4) |
733 HINIC_RSS_TYPE_SET(rss_type.udp_ipv6, UDP_IPV6);
735 cmd_buf.size = sizeof(struct hinic_rss_context_tbl);
737 ctx_tbl = (struct hinic_rss_context_tbl *)cmd_buf.buf;
738 ctx_tbl->group_index = cpu_to_be32(tmpl_idx);
740 ctx_tbl->size = sizeof(u32);
741 ctx_tbl->size = cpu_to_be32(ctx_tbl->size);
743 ctx_tbl->ctx = cpu_to_be32(ctx);
745 /* cfg the rss context table by command queue */
746 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC,
747 HINIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE,
748 &cmd_buf, &out_param);
750 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
752 if (err || out_param != 0) {
753 dev_err(&pdev->dev, "Failed to set rss context table, err: %d\n",
761 int hinic_get_rss_type(struct hinic_dev *nic_dev, u32 tmpl_idx,
762 struct hinic_rss_type *rss_type)
764 struct hinic_rss_context_table ctx_tbl = { 0 };
765 struct hinic_hwdev *hwdev = nic_dev->hwdev;
766 u16 out_size = sizeof(ctx_tbl);
767 struct hinic_hwif *hwif;
768 struct pci_dev *pdev;
771 if (!hwdev || !rss_type)
777 ctx_tbl.func_id = HINIC_HWIF_FUNC_IDX(hwif);
778 ctx_tbl.template_id = tmpl_idx;
780 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_CTX_TBL,
781 &ctx_tbl, sizeof(ctx_tbl),
782 &ctx_tbl, &out_size);
783 if (err || !out_size || ctx_tbl.status) {
784 dev_err(&pdev->dev, "Failed to get hash type, err: %d, status: 0x%x, out size: 0x%x\n",
785 err, ctx_tbl.status, out_size);
789 rss_type->ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV4);
790 rss_type->ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6);
791 rss_type->ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6_EXT);
792 rss_type->tcp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV4);
793 rss_type->tcp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6);
794 rss_type->tcp_ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context,
796 rss_type->udp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV4);
797 rss_type->udp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV6);
802 int hinic_rss_set_template_tbl(struct hinic_dev *nic_dev, u32 template_id,
805 struct hinic_hwdev *hwdev = nic_dev->hwdev;
806 struct hinic_hwif *hwif = hwdev->hwif;
807 struct hinic_rss_key rss_key = { 0 };
808 struct pci_dev *pdev = hwif->pdev;
809 u16 out_size = sizeof(rss_key);
812 rss_key.func_id = HINIC_HWIF_FUNC_IDX(hwif);
813 rss_key.template_id = template_id;
814 memcpy(rss_key.key, temp, HINIC_RSS_KEY_SIZE);
816 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RSS_TEMPLATE_TBL,
817 &rss_key, sizeof(rss_key),
818 &rss_key, &out_size);
819 if (err || !out_size || rss_key.status) {
821 "Failed to set rss hash key, err: %d, status: 0x%x, out size: 0x%x\n",
822 err, rss_key.status, out_size);
829 int hinic_rss_get_template_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx,
832 struct hinic_rss_template_key temp_key = { 0 };
833 struct hinic_hwdev *hwdev = nic_dev->hwdev;
834 u16 out_size = sizeof(temp_key);
835 struct hinic_hwif *hwif;
836 struct pci_dev *pdev;
845 temp_key.func_id = HINIC_HWIF_FUNC_IDX(hwif);
846 temp_key.template_id = tmpl_idx;
848 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_TBL,
849 &temp_key, sizeof(temp_key),
850 &temp_key, &out_size);
851 if (err || !out_size || temp_key.status) {
852 dev_err(&pdev->dev, "Failed to set hash key, err: %d, status: 0x%x, out size: 0x%x\n",
853 err, temp_key.status, out_size);
857 memcpy(temp, temp_key.key, HINIC_RSS_KEY_SIZE);
862 int hinic_rss_set_hash_engine(struct hinic_dev *nic_dev, u8 template_id,
865 struct hinic_rss_engine_type rss_engine = { 0 };
866 struct hinic_hwdev *hwdev = nic_dev->hwdev;
867 struct hinic_hwif *hwif = hwdev->hwif;
868 struct pci_dev *pdev = hwif->pdev;
869 u16 out_size = sizeof(rss_engine);
872 rss_engine.func_id = HINIC_HWIF_FUNC_IDX(hwif);
873 rss_engine.hash_engine = type;
874 rss_engine.template_id = template_id;
876 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RSS_HASH_ENGINE,
877 &rss_engine, sizeof(rss_engine),
878 &rss_engine, &out_size);
879 if (err || !out_size || rss_engine.status) {
881 "Failed to set hash engine, err: %d, status: 0x%x, out size: 0x%x\n",
882 err, rss_engine.status, out_size);
889 int hinic_rss_get_hash_engine(struct hinic_dev *nic_dev, u8 tmpl_idx, u8 *type)
891 struct hinic_rss_engine_type hash_type = { 0 };
892 struct hinic_hwdev *hwdev = nic_dev->hwdev;
893 u16 out_size = sizeof(hash_type);
894 struct hinic_hwif *hwif;
895 struct pci_dev *pdev;
904 hash_type.func_id = HINIC_HWIF_FUNC_IDX(hwif);
905 hash_type.template_id = tmpl_idx;
907 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_HASH_ENGINE,
908 &hash_type, sizeof(hash_type),
909 &hash_type, &out_size);
910 if (err || !out_size || hash_type.status) {
911 dev_err(&pdev->dev, "Failed to get hash engine, err: %d, status: 0x%x, out size: 0x%x\n",
912 err, hash_type.status, out_size);
916 *type = hash_type.hash_engine;
920 int hinic_rss_cfg(struct hinic_dev *nic_dev, u8 rss_en, u8 template_id)
922 struct hinic_hwdev *hwdev = nic_dev->hwdev;
923 struct hinic_rss_config rss_cfg = { 0 };
924 struct hinic_hwif *hwif = hwdev->hwif;
925 struct pci_dev *pdev = hwif->pdev;
926 u16 out_size = sizeof(rss_cfg);
929 rss_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
930 rss_cfg.rss_en = rss_en;
931 rss_cfg.template_id = template_id;
932 rss_cfg.rq_priority_number = 0;
934 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_CFG,
935 &rss_cfg, sizeof(rss_cfg),
936 &rss_cfg, &out_size);
937 if (err || !out_size || rss_cfg.status) {
939 "Failed to set rss cfg, err: %d, status: 0x%x, out size: 0x%x\n",
940 err, rss_cfg.status, out_size);
947 int hinic_rss_template_alloc(struct hinic_dev *nic_dev, u8 *tmpl_idx)
949 struct hinic_rss_template_mgmt template_mgmt = { 0 };
950 struct hinic_hwdev *hwdev = nic_dev->hwdev;
951 struct hinic_hwif *hwif = hwdev->hwif;
952 u16 out_size = sizeof(template_mgmt);
953 struct pci_dev *pdev = hwif->pdev;
956 template_mgmt.func_id = HINIC_HWIF_FUNC_IDX(hwif);
957 template_mgmt.cmd = NIC_RSS_CMD_TEMP_ALLOC;
959 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
960 &template_mgmt, sizeof(template_mgmt),
961 &template_mgmt, &out_size);
962 if (err || !out_size || template_mgmt.status) {
963 dev_err(&pdev->dev, "Failed to alloc rss template, err: %d, status: 0x%x, out size: 0x%x\n",
964 err, template_mgmt.status, out_size);
968 *tmpl_idx = template_mgmt.template_id;
973 int hinic_rss_template_free(struct hinic_dev *nic_dev, u8 tmpl_idx)
975 struct hinic_rss_template_mgmt template_mgmt = { 0 };
976 struct hinic_hwdev *hwdev = nic_dev->hwdev;
977 struct hinic_hwif *hwif = hwdev->hwif;
978 u16 out_size = sizeof(template_mgmt);
979 struct pci_dev *pdev = hwif->pdev;
982 template_mgmt.func_id = HINIC_HWIF_FUNC_IDX(hwif);
983 template_mgmt.template_id = tmpl_idx;
984 template_mgmt.cmd = NIC_RSS_CMD_TEMP_FREE;
986 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
987 &template_mgmt, sizeof(template_mgmt),
988 &template_mgmt, &out_size);
989 if (err || !out_size || template_mgmt.status) {
990 dev_err(&pdev->dev, "Failed to free rss template, err: %d, status: 0x%x, out size: 0x%x\n",
991 err, template_mgmt.status, out_size);
998 int hinic_get_vport_stats(struct hinic_dev *nic_dev,
999 struct hinic_vport_stats *stats)
1001 struct hinic_cmd_vport_stats vport_stats = { 0 };
1002 struct hinic_port_stats_info stats_info = { 0 };
1003 struct hinic_hwdev *hwdev = nic_dev->hwdev;
1004 struct hinic_hwif *hwif = hwdev->hwif;
1005 u16 out_size = sizeof(vport_stats);
1006 struct pci_dev *pdev = hwif->pdev;
1009 stats_info.stats_version = HINIC_PORT_STATS_VERSION;
1010 stats_info.func_id = HINIC_HWIF_FUNC_IDX(hwif);
1011 stats_info.stats_size = sizeof(vport_stats);
1013 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_VPORT_STAT,
1014 &stats_info, sizeof(stats_info),
1015 &vport_stats, &out_size);
1016 if (err || !out_size || vport_stats.status) {
1018 "Failed to get function statistics, err: %d, status: 0x%x, out size: 0x%x\n",
1019 err, vport_stats.status, out_size);
1023 memcpy(stats, &vport_stats.stats, sizeof(*stats));
1027 int hinic_get_phy_port_stats(struct hinic_dev *nic_dev,
1028 struct hinic_phy_port_stats *stats)
1030 struct hinic_port_stats_info stats_info = { 0 };
1031 struct hinic_hwdev *hwdev = nic_dev->hwdev;
1032 struct hinic_hwif *hwif = hwdev->hwif;
1033 struct hinic_port_stats *port_stats;
1034 u16 out_size = sizeof(*port_stats);
1035 struct pci_dev *pdev = hwif->pdev;
1038 port_stats = kzalloc(sizeof(*port_stats), GFP_KERNEL);
1042 stats_info.stats_version = HINIC_PORT_STATS_VERSION;
1043 stats_info.stats_size = sizeof(*port_stats);
1045 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_PORT_STATISTICS,
1046 &stats_info, sizeof(stats_info),
1047 port_stats, &out_size);
1048 if (err || !out_size || port_stats->status) {
1050 "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x\n",
1051 err, port_stats->status, out_size);
1056 memcpy(stats, &port_stats->stats, sizeof(*stats));
1064 int hinic_get_mgmt_version(struct hinic_dev *nic_dev, u8 *mgmt_ver)
1066 struct hinic_hwdev *hwdev = nic_dev->hwdev;
1067 struct hinic_version_info up_ver = {0};
1068 u16 out_size = sizeof(up_ver);
1069 struct hinic_hwif *hwif;
1070 struct pci_dev *pdev;
1079 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_MGMT_VERSION,
1080 &up_ver, sizeof(up_ver), &up_ver,
1082 if (err || !out_size || up_ver.status) {
1084 "Failed to get mgmt version, err: %d, status: 0x%x, out size: 0x%x\n",
1085 err, up_ver.status, out_size);
1089 snprintf(mgmt_ver, HINIC_MGMT_VERSION_MAX_LEN, "%s", up_ver.ver);
1094 int hinic_get_link_mode(struct hinic_hwdev *hwdev,
1095 struct hinic_link_mode_cmd *link_mode)
1100 if (!hwdev || !link_mode)
1103 link_mode->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1104 out_size = sizeof(*link_mode);
1106 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_LINK_MODE,
1107 link_mode, sizeof(*link_mode),
1108 link_mode, &out_size);
1109 if (err || !out_size || link_mode->status) {
1110 dev_err(&hwdev->hwif->pdev->dev,
1111 "Failed to get link mode, err: %d, status: 0x%x, out size: 0x%x\n",
1112 err, link_mode->status, out_size);
1119 int hinic_set_autoneg(struct hinic_hwdev *hwdev, bool enable)
1121 struct hinic_set_autoneg_cmd autoneg = {0};
1122 u16 out_size = sizeof(autoneg);
1128 autoneg.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1129 autoneg.enable = enable;
1131 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_AUTONEG,
1132 &autoneg, sizeof(autoneg),
1133 &autoneg, &out_size);
1134 if (err || !out_size || autoneg.status) {
1135 dev_err(&hwdev->hwif->pdev->dev, "Failed to %s autoneg, err: %d, status: 0x%x, out size: 0x%x\n",
1136 enable ? "enable" : "disable", err, autoneg.status,
1144 int hinic_set_speed(struct hinic_hwdev *hwdev, enum nic_speed_level speed)
1146 struct hinic_speed_cmd speed_info = {0};
1147 u16 out_size = sizeof(speed_info);
1153 speed_info.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1154 speed_info.speed = speed;
1156 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_SPEED,
1157 &speed_info, sizeof(speed_info),
1158 &speed_info, &out_size);
1159 if (err || !out_size || speed_info.status) {
1160 dev_err(&hwdev->hwif->pdev->dev,
1161 "Failed to set speed, err: %d, status: 0x%x, out size: 0x%x\n",
1162 err, speed_info.status, out_size);
1169 int hinic_set_link_settings(struct hinic_hwdev *hwdev,
1170 struct hinic_link_ksettings_info *info)
1172 u16 out_size = sizeof(*info);
1175 err = hinic_hilink_msg_cmd(hwdev, HINIC_HILINK_CMD_SET_LINK_SETTINGS,
1176 info, sizeof(*info), info, &out_size);
1177 if ((info->status != HINIC_MGMT_CMD_UNSUPPORTED &&
1178 info->status) || err || !out_size) {
1179 dev_err(&hwdev->hwif->pdev->dev,
1180 "Failed to set link settings, err: %d, status: 0x%x, out size: 0x%x\n",
1181 err, info->status, out_size);
1185 return info->status;
1188 int hinic_get_hw_pause_info(struct hinic_hwdev *hwdev,
1189 struct hinic_pause_config *pause_info)
1191 u16 out_size = sizeof(*pause_info);
1194 pause_info->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1196 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_PAUSE_INFO,
1197 pause_info, sizeof(*pause_info),
1198 pause_info, &out_size);
1199 if (err || !out_size || pause_info->status) {
1200 dev_err(&hwdev->hwif->pdev->dev, "Failed to get pause info, err: %d, status: 0x%x, out size: 0x%x\n",
1201 err, pause_info->status, out_size);
1208 int hinic_set_hw_pause_info(struct hinic_hwdev *hwdev,
1209 struct hinic_pause_config *pause_info)
1211 u16 out_size = sizeof(*pause_info);
1214 pause_info->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1216 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PAUSE_INFO,
1217 pause_info, sizeof(*pause_info),
1218 pause_info, &out_size);
1219 if (err || !out_size || pause_info->status) {
1220 dev_err(&hwdev->hwif->pdev->dev, "Failed to set pause info, err: %d, status: 0x%x, out size: 0x%x\n",
1221 err, pause_info->status, out_size);
1228 int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap)
1230 struct hinic_nic_cfg *nic_cfg = &hwdev->func_to_io.nic_cfg;
1231 struct hinic_set_pfc pfc = {0};
1232 u16 out_size = sizeof(pfc);
1235 if (HINIC_IS_VF(hwdev->hwif))
1238 mutex_lock(&nic_cfg->cfg_mutex);
1240 pfc.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1241 pfc.pfc_bitmap = pfc_bitmap;
1242 pfc.pfc_en = pfc_en;
1244 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PFC,
1245 &pfc, sizeof(pfc), &pfc, &out_size);
1246 if (err || pfc.status || !out_size) {
1247 dev_err(&hwdev->hwif->pdev->dev, "Failed to %s pfc, err: %d, status: 0x%x, out size: 0x%x\n",
1248 pfc_en ? "enable" : "disable", err, pfc.status,
1250 mutex_unlock(&nic_cfg->cfg_mutex);
1254 /* pause settings is opposite from pfc */
1255 nic_cfg->rx_pause = pfc_en ? 0 : 1;
1256 nic_cfg->tx_pause = pfc_en ? 0 : 1;
1258 mutex_unlock(&nic_cfg->cfg_mutex);
1263 int hinic_set_loopback_mode(struct hinic_hwdev *hwdev, u32 mode, u32 enable)
1265 struct hinic_port_loopback lb = {0};
1266 u16 out_size = sizeof(lb);
1272 if (mode < LOOP_MODE_MIN || mode > LOOP_MODE_MAX) {
1273 dev_err(&hwdev->hwif->pdev->dev,
1274 "Invalid loopback mode %d to set\n", mode);
1278 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LOOPBACK_MODE,
1279 &lb, sizeof(lb), &lb, &out_size);
1280 if (err || !out_size || lb.status) {
1281 dev_err(&hwdev->hwif->pdev->dev,
1282 "Failed to set loopback mode %d en %d, err: %d, status: 0x%x, out size: 0x%x\n",
1283 mode, enable, err, lb.status, out_size);
1290 static int _set_led_status(struct hinic_hwdev *hwdev, u8 port,
1291 enum hinic_led_type type,
1292 enum hinic_led_mode mode, u8 reset)
1294 struct hinic_led_info led_info = {0};
1295 u16 out_size = sizeof(led_info);
1296 struct hinic_pfhwdev *pfhwdev;
1299 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev);
1301 led_info.port = port;
1302 led_info.reset = reset;
1304 led_info.type = type;
1305 led_info.mode = mode;
1307 err = hinic_msg_to_mgmt(&pfhwdev->pf_to_mgmt, HINIC_MOD_COMM,
1308 HINIC_COMM_CMD_SET_LED_STATUS,
1309 &led_info, sizeof(led_info),
1310 &led_info, &out_size, HINIC_MGMT_MSG_SYNC);
1311 if (err || led_info.status || !out_size) {
1312 dev_err(&hwdev->hwif->pdev->dev, "Failed to set led status, err: %d, status: 0x%x, out size: 0x%x\n",
1313 err, led_info.status, out_size);
1320 int hinic_set_led_status(struct hinic_hwdev *hwdev, u8 port,
1321 enum hinic_led_type type, enum hinic_led_mode mode)
1326 return _set_led_status(hwdev, port, type, mode, 0);
1329 int hinic_reset_led_status(struct hinic_hwdev *hwdev, u8 port)
1336 err = _set_led_status(hwdev, port, HINIC_LED_TYPE_INVALID,
1337 HINIC_LED_MODE_INVALID, 1);
1339 dev_err(&hwdev->hwif->pdev->dev,
1340 "Failed to reset led status\n");
1345 static bool hinic_if_sfp_absent(struct hinic_hwdev *hwdev)
1347 struct hinic_cmd_get_light_module_abs sfp_abs = {0};
1348 u16 out_size = sizeof(sfp_abs);
1349 u8 port_id = hwdev->port_id;
1352 sfp_abs.port_id = port_id;
1353 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_SFP_ABS,
1354 &sfp_abs, sizeof(sfp_abs), &sfp_abs,
1356 if (sfp_abs.status || err || !out_size) {
1357 dev_err(&hwdev->hwif->pdev->dev,
1358 "Failed to get port%d sfp absent status, err: %d, status: 0x%x, out size: 0x%x\n",
1359 port_id, err, sfp_abs.status, out_size);
1363 return ((sfp_abs.abs_status == 0) ? false : true);
1366 int hinic_get_sfp_eeprom(struct hinic_hwdev *hwdev, u8 *data, u16 *len)
1368 struct hinic_cmd_get_std_sfp_info sfp_info = {0};
1369 u16 out_size = sizeof(sfp_info);
1373 if (!hwdev || !data || !len)
1376 port_id = hwdev->port_id;
1378 if (hinic_if_sfp_absent(hwdev))
1381 sfp_info.port_id = port_id;
1382 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_STD_SFP_INFO,
1383 &sfp_info, sizeof(sfp_info), &sfp_info,
1385 if (sfp_info.status || err || !out_size) {
1386 dev_err(&hwdev->hwif->pdev->dev,
1387 "Failed to get port%d sfp eeprom information, err: %d, status: 0x%x, out size: 0x%x\n",
1388 port_id, err, sfp_info.status, out_size);
1392 *len = min_t(u16, sfp_info.eeprom_len, STD_SFP_INFO_MAX_SIZE);
1393 memcpy(data, sfp_info.sfp_info, STD_SFP_INFO_MAX_SIZE);
1398 int hinic_get_sfp_type(struct hinic_hwdev *hwdev, u8 *data0, u8 *data1)
1400 u8 sfp_data[STD_SFP_INFO_MAX_SIZE];
1404 if (hinic_if_sfp_absent(hwdev))
1407 err = hinic_get_sfp_eeprom(hwdev, sfp_data, &len);
1411 *data0 = sfp_data[0];
1412 *data1 = sfp_data[1];