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);
459 vlan_filter.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
460 vlan_filter.enable = en;
462 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_VLAN_FILTER,
463 &vlan_filter, sizeof(vlan_filter),
464 &vlan_filter, &out_size);
465 if (vlan_filter.status == HINIC_MGMT_CMD_UNSUPPORTED) {
466 err = HINIC_MGMT_CMD_UNSUPPORTED;
467 } else if ((err == HINIC_MBOX_VF_CMD_ERROR) &&
469 err = HINIC_MGMT_CMD_UNSUPPORTED;
470 } else if (err || !out_size || vlan_filter.status) {
472 "Failed to set vlan fliter, err: %d, status: 0x%x, out size: 0x%x\n",
473 err, vlan_filter.status, out_size);
480 int hinic_set_max_qnum(struct hinic_dev *nic_dev, u8 num_rqs)
482 struct hinic_hwdev *hwdev = nic_dev->hwdev;
483 struct hinic_hwif *hwif = hwdev->hwif;
484 struct hinic_rq_num rq_num = { 0 };
485 struct pci_dev *pdev = hwif->pdev;
486 u16 out_size = sizeof(rq_num);
489 rq_num.func_id = HINIC_HWIF_FUNC_IDX(hwif);
490 rq_num.num_rqs = num_rqs;
491 rq_num.rq_depth = ilog2(nic_dev->rq_depth);
493 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RQ_IQ_MAP,
494 &rq_num, sizeof(rq_num),
496 if (err || !out_size || rq_num.status) {
498 "Failed to set rxq number, err: %d, status: 0x%x, out size: 0x%x\n",
499 err, rq_num.status, out_size);
506 static int hinic_set_rx_lro(struct hinic_dev *nic_dev, u8 ipv4_en, u8 ipv6_en,
509 struct hinic_hwdev *hwdev = nic_dev->hwdev;
510 struct hinic_lro_config lro_cfg = { 0 };
511 struct hinic_hwif *hwif = hwdev->hwif;
512 struct pci_dev *pdev = hwif->pdev;
513 u16 out_size = sizeof(lro_cfg);
516 lro_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
517 lro_cfg.lro_ipv4_en = ipv4_en;
518 lro_cfg.lro_ipv6_en = ipv6_en;
519 lro_cfg.lro_max_wqe_num = max_wqe_num;
521 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO,
522 &lro_cfg, sizeof(lro_cfg),
523 &lro_cfg, &out_size);
524 if (err || !out_size || lro_cfg.status) {
526 "Failed to set lro offload, err: %d, status: 0x%x, out size: 0x%x\n",
527 err, lro_cfg.status, out_size);
534 static int hinic_set_rx_lro_timer(struct hinic_dev *nic_dev, u32 timer_value)
536 struct hinic_hwdev *hwdev = nic_dev->hwdev;
537 struct hinic_lro_timer lro_timer = { 0 };
538 struct hinic_hwif *hwif = hwdev->hwif;
539 struct pci_dev *pdev = hwif->pdev;
540 u16 out_size = sizeof(lro_timer);
543 lro_timer.status = 0;
545 lro_timer.enable = 1;
546 lro_timer.timer = timer_value;
548 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO_TIMER,
549 &lro_timer, sizeof(lro_timer),
550 &lro_timer, &out_size);
551 if (lro_timer.status == 0xFF) {
552 /* For this case, we think status (0xFF) is OK */
553 lro_timer.status = 0;
555 "Set lro timer not supported by the current FW version, it will be 1ms default\n");
558 if (err || !out_size || lro_timer.status) {
560 "Failed to set lro timer, err: %d, status: 0x%x, out size: 0x%x\n",
561 err, lro_timer.status, out_size);
569 int hinic_set_rx_lro_state(struct hinic_dev *nic_dev, u8 lro_en,
570 u32 lro_timer, u32 wqe_num)
572 struct hinic_hwdev *hwdev = nic_dev->hwdev;
580 ipv4_en = lro_en ? 1 : 0;
581 ipv6_en = lro_en ? 1 : 0;
583 err = hinic_set_rx_lro(nic_dev, ipv4_en, ipv6_en, (u8)wqe_num);
587 if (HINIC_IS_VF(nic_dev->hwdev->hwif))
590 err = hinic_set_rx_lro_timer(nic_dev, lro_timer);
597 int hinic_rss_set_indir_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx,
598 const u32 *indir_table)
600 struct hinic_rss_indirect_tbl *indir_tbl;
601 struct hinic_func_to_io *func_to_io;
602 struct hinic_cmdq_buf cmd_buf;
603 struct hinic_hwdev *hwdev;
604 struct hinic_hwif *hwif;
605 struct pci_dev *pdev;
611 hwdev = nic_dev->hwdev;
612 func_to_io = &hwdev->func_to_io;
616 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
618 dev_err(&pdev->dev, "Failed to allocate cmdq buf\n");
622 cmd_buf.size = sizeof(*indir_tbl);
624 indir_tbl = cmd_buf.buf;
625 indir_tbl->group_index = cpu_to_be32(tmpl_idx);
627 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) {
628 indir_tbl->entry[i] = indir_table[i];
630 if (0x3 == (i & 0x3)) {
631 temp = (u32 *)&indir_tbl->entry[i - 3];
632 *temp = cpu_to_be32(*temp);
636 /* cfg the rss indirect table by command queue */
637 indir_size = HINIC_RSS_INDIR_SIZE / 2;
638 indir_tbl->offset = 0;
639 indir_tbl->size = cpu_to_be32(indir_size);
641 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC,
642 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
643 &cmd_buf, &out_param);
644 if (err || out_param != 0) {
645 dev_err(&pdev->dev, "Failed to set rss indir table\n");
650 indir_tbl->offset = cpu_to_be32(indir_size);
651 indir_tbl->size = cpu_to_be32(indir_size);
652 memcpy(&indir_tbl->entry[0], &indir_tbl->entry[indir_size], indir_size);
654 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC,
655 HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE,
656 &cmd_buf, &out_param);
657 if (err || out_param != 0) {
658 dev_err(&pdev->dev, "Failed to set rss indir table\n");
663 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
668 int hinic_rss_get_indir_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx,
671 struct hinic_rss_indir_table rss_cfg = { 0 };
672 struct hinic_hwdev *hwdev = nic_dev->hwdev;
673 struct hinic_hwif *hwif = hwdev->hwif;
674 struct pci_dev *pdev = hwif->pdev;
675 u16 out_size = sizeof(rss_cfg);
678 rss_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
679 rss_cfg.template_id = tmpl_idx;
681 err = hinic_port_msg_cmd(hwdev,
682 HINIC_PORT_CMD_GET_RSS_TEMPLATE_INDIR_TBL,
683 &rss_cfg, sizeof(rss_cfg), &rss_cfg,
685 if (err || !out_size || rss_cfg.status) {
686 dev_err(&pdev->dev, "Failed to get indir table, err: %d, status: 0x%x, out size: 0x%x\n",
687 err, rss_cfg.status, out_size);
691 hinic_be32_to_cpu(rss_cfg.indir, HINIC_RSS_INDIR_SIZE);
692 for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++)
693 indir_table[i] = rss_cfg.indir[i];
698 int hinic_set_rss_type(struct hinic_dev *nic_dev, u32 tmpl_idx,
699 struct hinic_rss_type rss_type)
701 struct hinic_rss_context_tbl *ctx_tbl;
702 struct hinic_func_to_io *func_to_io;
703 struct hinic_cmdq_buf cmd_buf;
704 struct hinic_hwdev *hwdev;
705 struct hinic_hwif *hwif;
706 struct pci_dev *pdev;
711 hwdev = nic_dev->hwdev;
712 func_to_io = &hwdev->func_to_io;
716 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
718 dev_err(&pdev->dev, "Failed to allocate cmd buf\n");
722 ctx |= HINIC_RSS_TYPE_SET(1, VALID) |
723 HINIC_RSS_TYPE_SET(rss_type.ipv4, IPV4) |
724 HINIC_RSS_TYPE_SET(rss_type.ipv6, IPV6) |
725 HINIC_RSS_TYPE_SET(rss_type.ipv6_ext, IPV6_EXT) |
726 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv4, TCP_IPV4) |
727 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6, TCP_IPV6) |
728 HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6_ext, TCP_IPV6_EXT) |
729 HINIC_RSS_TYPE_SET(rss_type.udp_ipv4, UDP_IPV4) |
730 HINIC_RSS_TYPE_SET(rss_type.udp_ipv6, UDP_IPV6);
732 cmd_buf.size = sizeof(struct hinic_rss_context_tbl);
734 ctx_tbl = (struct hinic_rss_context_tbl *)cmd_buf.buf;
735 ctx_tbl->group_index = cpu_to_be32(tmpl_idx);
737 ctx_tbl->size = sizeof(u32);
738 ctx_tbl->size = cpu_to_be32(ctx_tbl->size);
740 ctx_tbl->ctx = cpu_to_be32(ctx);
742 /* cfg the rss context table by command queue */
743 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC,
744 HINIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE,
745 &cmd_buf, &out_param);
747 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmd_buf);
749 if (err || out_param != 0) {
750 dev_err(&pdev->dev, "Failed to set rss context table, err: %d\n",
758 int hinic_get_rss_type(struct hinic_dev *nic_dev, u32 tmpl_idx,
759 struct hinic_rss_type *rss_type)
761 struct hinic_rss_context_table ctx_tbl = { 0 };
762 struct hinic_hwdev *hwdev = nic_dev->hwdev;
763 u16 out_size = sizeof(ctx_tbl);
764 struct hinic_hwif *hwif;
765 struct pci_dev *pdev;
768 if (!hwdev || !rss_type)
774 ctx_tbl.func_id = HINIC_HWIF_FUNC_IDX(hwif);
775 ctx_tbl.template_id = tmpl_idx;
777 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_CTX_TBL,
778 &ctx_tbl, sizeof(ctx_tbl),
779 &ctx_tbl, &out_size);
780 if (err || !out_size || ctx_tbl.status) {
781 dev_err(&pdev->dev, "Failed to get hash type, err: %d, status: 0x%x, out size: 0x%x\n",
782 err, ctx_tbl.status, out_size);
786 rss_type->ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV4);
787 rss_type->ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6);
788 rss_type->ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6_EXT);
789 rss_type->tcp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV4);
790 rss_type->tcp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6);
791 rss_type->tcp_ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context,
793 rss_type->udp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV4);
794 rss_type->udp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV6);
799 int hinic_rss_set_template_tbl(struct hinic_dev *nic_dev, u32 template_id,
802 struct hinic_hwdev *hwdev = nic_dev->hwdev;
803 struct hinic_hwif *hwif = hwdev->hwif;
804 struct hinic_rss_key rss_key = { 0 };
805 struct pci_dev *pdev = hwif->pdev;
806 u16 out_size = sizeof(rss_key);
809 rss_key.func_id = HINIC_HWIF_FUNC_IDX(hwif);
810 rss_key.template_id = template_id;
811 memcpy(rss_key.key, temp, HINIC_RSS_KEY_SIZE);
813 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RSS_TEMPLATE_TBL,
814 &rss_key, sizeof(rss_key),
815 &rss_key, &out_size);
816 if (err || !out_size || rss_key.status) {
818 "Failed to set rss hash key, err: %d, status: 0x%x, out size: 0x%x\n",
819 err, rss_key.status, out_size);
826 int hinic_rss_get_template_tbl(struct hinic_dev *nic_dev, u32 tmpl_idx,
829 struct hinic_rss_template_key temp_key = { 0 };
830 struct hinic_hwdev *hwdev = nic_dev->hwdev;
831 u16 out_size = sizeof(temp_key);
832 struct hinic_hwif *hwif;
833 struct pci_dev *pdev;
842 temp_key.func_id = HINIC_HWIF_FUNC_IDX(hwif);
843 temp_key.template_id = tmpl_idx;
845 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_TBL,
846 &temp_key, sizeof(temp_key),
847 &temp_key, &out_size);
848 if (err || !out_size || temp_key.status) {
849 dev_err(&pdev->dev, "Failed to set hash key, err: %d, status: 0x%x, out size: 0x%x\n",
850 err, temp_key.status, out_size);
854 memcpy(temp, temp_key.key, HINIC_RSS_KEY_SIZE);
859 int hinic_rss_set_hash_engine(struct hinic_dev *nic_dev, u8 template_id,
862 struct hinic_rss_engine_type rss_engine = { 0 };
863 struct hinic_hwdev *hwdev = nic_dev->hwdev;
864 struct hinic_hwif *hwif = hwdev->hwif;
865 struct pci_dev *pdev = hwif->pdev;
866 u16 out_size = sizeof(rss_engine);
869 rss_engine.func_id = HINIC_HWIF_FUNC_IDX(hwif);
870 rss_engine.hash_engine = type;
871 rss_engine.template_id = template_id;
873 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RSS_HASH_ENGINE,
874 &rss_engine, sizeof(rss_engine),
875 &rss_engine, &out_size);
876 if (err || !out_size || rss_engine.status) {
878 "Failed to set hash engine, err: %d, status: 0x%x, out size: 0x%x\n",
879 err, rss_engine.status, out_size);
886 int hinic_rss_get_hash_engine(struct hinic_dev *nic_dev, u8 tmpl_idx, u8 *type)
888 struct hinic_rss_engine_type hash_type = { 0 };
889 struct hinic_hwdev *hwdev = nic_dev->hwdev;
890 u16 out_size = sizeof(hash_type);
891 struct hinic_hwif *hwif;
892 struct pci_dev *pdev;
901 hash_type.func_id = HINIC_HWIF_FUNC_IDX(hwif);
902 hash_type.template_id = tmpl_idx;
904 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_RSS_HASH_ENGINE,
905 &hash_type, sizeof(hash_type),
906 &hash_type, &out_size);
907 if (err || !out_size || hash_type.status) {
908 dev_err(&pdev->dev, "Failed to get hash engine, err: %d, status: 0x%x, out size: 0x%x\n",
909 err, hash_type.status, out_size);
913 *type = hash_type.hash_engine;
917 int hinic_rss_cfg(struct hinic_dev *nic_dev, u8 rss_en, u8 template_id)
919 struct hinic_hwdev *hwdev = nic_dev->hwdev;
920 struct hinic_rss_config rss_cfg = { 0 };
921 struct hinic_hwif *hwif = hwdev->hwif;
922 struct pci_dev *pdev = hwif->pdev;
923 u16 out_size = sizeof(rss_cfg);
926 rss_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
927 rss_cfg.rss_en = rss_en;
928 rss_cfg.template_id = template_id;
929 rss_cfg.rq_priority_number = 0;
931 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_CFG,
932 &rss_cfg, sizeof(rss_cfg),
933 &rss_cfg, &out_size);
934 if (err || !out_size || rss_cfg.status) {
936 "Failed to set rss cfg, err: %d, status: 0x%x, out size: 0x%x\n",
937 err, rss_cfg.status, out_size);
944 int hinic_rss_template_alloc(struct hinic_dev *nic_dev, u8 *tmpl_idx)
946 struct hinic_rss_template_mgmt template_mgmt = { 0 };
947 struct hinic_hwdev *hwdev = nic_dev->hwdev;
948 struct hinic_hwif *hwif = hwdev->hwif;
949 u16 out_size = sizeof(template_mgmt);
950 struct pci_dev *pdev = hwif->pdev;
953 template_mgmt.func_id = HINIC_HWIF_FUNC_IDX(hwif);
954 template_mgmt.cmd = NIC_RSS_CMD_TEMP_ALLOC;
956 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
957 &template_mgmt, sizeof(template_mgmt),
958 &template_mgmt, &out_size);
959 if (err || !out_size || template_mgmt.status) {
960 dev_err(&pdev->dev, "Failed to alloc rss template, err: %d, status: 0x%x, out size: 0x%x\n",
961 err, template_mgmt.status, out_size);
965 *tmpl_idx = template_mgmt.template_id;
970 int hinic_rss_template_free(struct hinic_dev *nic_dev, u8 tmpl_idx)
972 struct hinic_rss_template_mgmt template_mgmt = { 0 };
973 struct hinic_hwdev *hwdev = nic_dev->hwdev;
974 struct hinic_hwif *hwif = hwdev->hwif;
975 u16 out_size = sizeof(template_mgmt);
976 struct pci_dev *pdev = hwif->pdev;
979 template_mgmt.func_id = HINIC_HWIF_FUNC_IDX(hwif);
980 template_mgmt.template_id = tmpl_idx;
981 template_mgmt.cmd = NIC_RSS_CMD_TEMP_FREE;
983 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR,
984 &template_mgmt, sizeof(template_mgmt),
985 &template_mgmt, &out_size);
986 if (err || !out_size || template_mgmt.status) {
987 dev_err(&pdev->dev, "Failed to free rss template, err: %d, status: 0x%x, out size: 0x%x\n",
988 err, template_mgmt.status, out_size);
995 int hinic_get_vport_stats(struct hinic_dev *nic_dev,
996 struct hinic_vport_stats *stats)
998 struct hinic_cmd_vport_stats vport_stats = { 0 };
999 struct hinic_port_stats_info stats_info = { 0 };
1000 struct hinic_hwdev *hwdev = nic_dev->hwdev;
1001 struct hinic_hwif *hwif = hwdev->hwif;
1002 u16 out_size = sizeof(vport_stats);
1003 struct pci_dev *pdev = hwif->pdev;
1006 stats_info.stats_version = HINIC_PORT_STATS_VERSION;
1007 stats_info.func_id = HINIC_HWIF_FUNC_IDX(hwif);
1008 stats_info.stats_size = sizeof(vport_stats);
1010 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_VPORT_STAT,
1011 &stats_info, sizeof(stats_info),
1012 &vport_stats, &out_size);
1013 if (err || !out_size || vport_stats.status) {
1015 "Failed to get function statistics, err: %d, status: 0x%x, out size: 0x%x\n",
1016 err, vport_stats.status, out_size);
1020 memcpy(stats, &vport_stats.stats, sizeof(*stats));
1024 int hinic_get_phy_port_stats(struct hinic_dev *nic_dev,
1025 struct hinic_phy_port_stats *stats)
1027 struct hinic_port_stats_info stats_info = { 0 };
1028 struct hinic_hwdev *hwdev = nic_dev->hwdev;
1029 struct hinic_hwif *hwif = hwdev->hwif;
1030 struct hinic_port_stats *port_stats;
1031 u16 out_size = sizeof(*port_stats);
1032 struct pci_dev *pdev = hwif->pdev;
1035 port_stats = kzalloc(sizeof(*port_stats), GFP_KERNEL);
1039 stats_info.stats_version = HINIC_PORT_STATS_VERSION;
1040 stats_info.stats_size = sizeof(*port_stats);
1042 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_PORT_STATISTICS,
1043 &stats_info, sizeof(stats_info),
1044 port_stats, &out_size);
1045 if (err || !out_size || port_stats->status) {
1047 "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x\n",
1048 err, port_stats->status, out_size);
1053 memcpy(stats, &port_stats->stats, sizeof(*stats));
1061 int hinic_get_mgmt_version(struct hinic_dev *nic_dev, u8 *mgmt_ver)
1063 struct hinic_hwdev *hwdev = nic_dev->hwdev;
1064 struct hinic_version_info up_ver = {0};
1065 u16 out_size = sizeof(up_ver);
1066 struct hinic_hwif *hwif;
1067 struct pci_dev *pdev;
1076 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_MGMT_VERSION,
1077 &up_ver, sizeof(up_ver), &up_ver,
1079 if (err || !out_size || up_ver.status) {
1081 "Failed to get mgmt version, err: %d, status: 0x%x, out size: 0x%x\n",
1082 err, up_ver.status, out_size);
1086 snprintf(mgmt_ver, HINIC_MGMT_VERSION_MAX_LEN, "%s", up_ver.ver);
1091 int hinic_get_link_mode(struct hinic_hwdev *hwdev,
1092 struct hinic_link_mode_cmd *link_mode)
1097 if (!hwdev || !link_mode)
1100 link_mode->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1101 out_size = sizeof(*link_mode);
1103 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_LINK_MODE,
1104 link_mode, sizeof(*link_mode),
1105 link_mode, &out_size);
1106 if (err || !out_size || link_mode->status) {
1107 dev_err(&hwdev->hwif->pdev->dev,
1108 "Failed to get link mode, err: %d, status: 0x%x, out size: 0x%x\n",
1109 err, link_mode->status, out_size);
1116 int hinic_set_autoneg(struct hinic_hwdev *hwdev, bool enable)
1118 struct hinic_set_autoneg_cmd autoneg = {0};
1119 u16 out_size = sizeof(autoneg);
1125 autoneg.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1126 autoneg.enable = enable;
1128 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_AUTONEG,
1129 &autoneg, sizeof(autoneg),
1130 &autoneg, &out_size);
1131 if (err || !out_size || autoneg.status) {
1132 dev_err(&hwdev->hwif->pdev->dev, "Failed to %s autoneg, err: %d, status: 0x%x, out size: 0x%x\n",
1133 enable ? "enable" : "disable", err, autoneg.status,
1141 int hinic_set_speed(struct hinic_hwdev *hwdev, enum nic_speed_level speed)
1143 struct hinic_speed_cmd speed_info = {0};
1144 u16 out_size = sizeof(speed_info);
1150 speed_info.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1151 speed_info.speed = speed;
1153 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_SPEED,
1154 &speed_info, sizeof(speed_info),
1155 &speed_info, &out_size);
1156 if (err || !out_size || speed_info.status) {
1157 dev_err(&hwdev->hwif->pdev->dev,
1158 "Failed to set speed, err: %d, status: 0x%x, out size: 0x%x\n",
1159 err, speed_info.status, out_size);
1166 int hinic_set_link_settings(struct hinic_hwdev *hwdev,
1167 struct hinic_link_ksettings_info *info)
1169 u16 out_size = sizeof(*info);
1172 err = hinic_hilink_msg_cmd(hwdev, HINIC_HILINK_CMD_SET_LINK_SETTINGS,
1173 info, sizeof(*info), info, &out_size);
1174 if ((info->status != HINIC_MGMT_CMD_UNSUPPORTED &&
1175 info->status) || err || !out_size) {
1176 dev_err(&hwdev->hwif->pdev->dev,
1177 "Failed to set link settings, err: %d, status: 0x%x, out size: 0x%x\n",
1178 err, info->status, out_size);
1182 return info->status;
1185 int hinic_get_hw_pause_info(struct hinic_hwdev *hwdev,
1186 struct hinic_pause_config *pause_info)
1188 u16 out_size = sizeof(*pause_info);
1191 pause_info->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1193 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_PAUSE_INFO,
1194 pause_info, sizeof(*pause_info),
1195 pause_info, &out_size);
1196 if (err || !out_size || pause_info->status) {
1197 dev_err(&hwdev->hwif->pdev->dev, "Failed to get pause info, err: %d, status: 0x%x, out size: 0x%x\n",
1198 err, pause_info->status, out_size);
1205 int hinic_set_hw_pause_info(struct hinic_hwdev *hwdev,
1206 struct hinic_pause_config *pause_info)
1208 u16 out_size = sizeof(*pause_info);
1211 pause_info->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1213 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PAUSE_INFO,
1214 pause_info, sizeof(*pause_info),
1215 pause_info, &out_size);
1216 if (err || !out_size || pause_info->status) {
1217 dev_err(&hwdev->hwif->pdev->dev, "Failed to set pause info, err: %d, status: 0x%x, out size: 0x%x\n",
1218 err, pause_info->status, out_size);
1225 int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap)
1227 struct hinic_nic_cfg *nic_cfg = &hwdev->func_to_io.nic_cfg;
1228 struct hinic_set_pfc pfc = {0};
1229 u16 out_size = sizeof(pfc);
1232 if (HINIC_IS_VF(hwdev->hwif))
1235 mutex_lock(&nic_cfg->cfg_mutex);
1237 pfc.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif);
1238 pfc.pfc_bitmap = pfc_bitmap;
1239 pfc.pfc_en = pfc_en;
1241 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_PFC,
1242 &pfc, sizeof(pfc), &pfc, &out_size);
1243 if (err || pfc.status || !out_size) {
1244 dev_err(&hwdev->hwif->pdev->dev, "Failed to %s pfc, err: %d, status: 0x%x, out size: 0x%x\n",
1245 pfc_en ? "enable" : "disable", err, pfc.status,
1247 mutex_unlock(&nic_cfg->cfg_mutex);
1251 /* pause settings is opposite from pfc */
1252 nic_cfg->rx_pause = pfc_en ? 0 : 1;
1253 nic_cfg->tx_pause = pfc_en ? 0 : 1;
1255 mutex_unlock(&nic_cfg->cfg_mutex);
1260 int hinic_set_loopback_mode(struct hinic_hwdev *hwdev, u32 mode, u32 enable)
1262 struct hinic_port_loopback lb = {0};
1263 u16 out_size = sizeof(lb);
1269 if (mode < LOOP_MODE_MIN || mode > LOOP_MODE_MAX) {
1270 dev_err(&hwdev->hwif->pdev->dev,
1271 "Invalid loopback mode %d to set\n", mode);
1275 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LOOPBACK_MODE,
1276 &lb, sizeof(lb), &lb, &out_size);
1277 if (err || !out_size || lb.status) {
1278 dev_err(&hwdev->hwif->pdev->dev,
1279 "Failed to set loopback mode %d en %d, err: %d, status: 0x%x, out size: 0x%x\n",
1280 mode, enable, err, lb.status, out_size);
1287 static int _set_led_status(struct hinic_hwdev *hwdev, u8 port,
1288 enum hinic_led_type type,
1289 enum hinic_led_mode mode, u8 reset)
1291 struct hinic_led_info led_info = {0};
1292 u16 out_size = sizeof(led_info);
1293 struct hinic_pfhwdev *pfhwdev;
1296 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev);
1298 led_info.port = port;
1299 led_info.reset = reset;
1301 led_info.type = type;
1302 led_info.mode = mode;
1304 err = hinic_msg_to_mgmt(&pfhwdev->pf_to_mgmt, HINIC_MOD_COMM,
1305 HINIC_COMM_CMD_SET_LED_STATUS,
1306 &led_info, sizeof(led_info),
1307 &led_info, &out_size, HINIC_MGMT_MSG_SYNC);
1308 if (err || led_info.status || !out_size) {
1309 dev_err(&hwdev->hwif->pdev->dev, "Failed to set led status, err: %d, status: 0x%x, out size: 0x%x\n",
1310 err, led_info.status, out_size);
1317 int hinic_set_led_status(struct hinic_hwdev *hwdev, u8 port,
1318 enum hinic_led_type type, enum hinic_led_mode mode)
1323 return _set_led_status(hwdev, port, type, mode, 0);
1326 int hinic_reset_led_status(struct hinic_hwdev *hwdev, u8 port)
1333 err = _set_led_status(hwdev, port, HINIC_LED_TYPE_INVALID,
1334 HINIC_LED_MODE_INVALID, 1);
1336 dev_err(&hwdev->hwif->pdev->dev,
1337 "Failed to reset led status\n");
1342 static bool hinic_if_sfp_absent(struct hinic_hwdev *hwdev)
1344 struct hinic_cmd_get_light_module_abs sfp_abs = {0};
1345 u16 out_size = sizeof(sfp_abs);
1346 u8 port_id = hwdev->port_id;
1349 sfp_abs.port_id = port_id;
1350 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_SFP_ABS,
1351 &sfp_abs, sizeof(sfp_abs), &sfp_abs,
1353 if (sfp_abs.status || err || !out_size) {
1354 dev_err(&hwdev->hwif->pdev->dev,
1355 "Failed to get port%d sfp absent status, err: %d, status: 0x%x, out size: 0x%x\n",
1356 port_id, err, sfp_abs.status, out_size);
1360 return ((sfp_abs.abs_status == 0) ? false : true);
1363 int hinic_get_sfp_eeprom(struct hinic_hwdev *hwdev, u8 *data, u16 *len)
1365 struct hinic_cmd_get_std_sfp_info sfp_info = {0};
1366 u16 out_size = sizeof(sfp_info);
1370 if (!hwdev || !data || !len)
1373 port_id = hwdev->port_id;
1375 if (hinic_if_sfp_absent(hwdev))
1378 sfp_info.port_id = port_id;
1379 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_STD_SFP_INFO,
1380 &sfp_info, sizeof(sfp_info), &sfp_info,
1382 if (sfp_info.status || err || !out_size) {
1383 dev_err(&hwdev->hwif->pdev->dev,
1384 "Failed to get port%d sfp eeprom information, err: %d, status: 0x%x, out size: 0x%x\n",
1385 port_id, err, sfp_info.status, out_size);
1389 *len = min_t(u16, sfp_info.eeprom_len, STD_SFP_INFO_MAX_SIZE);
1390 memcpy(data, sfp_info.sfp_info, STD_SFP_INFO_MAX_SIZE);
1395 int hinic_get_sfp_type(struct hinic_hwdev *hwdev, u8 *data0, u8 *data1)
1397 u8 sfp_data[STD_SFP_INFO_MAX_SIZE];
1401 if (hinic_if_sfp_absent(hwdev))
1404 err = hinic_get_sfp_eeprom(hwdev, sfp_data, &len);
1408 *data0 = sfp_data[0];
1409 *data1 = sfp_data[1];