Lines Matching refs:nic_dev
79 static int set_features(struct hinic_dev *nic_dev,
110 static void gather_nic_stats(struct hinic_dev *nic_dev, in gather_nic_stats() argument
114 int i, num_qps = hinic_hwdev_num_qps(nic_dev->hwdev); in gather_nic_stats()
117 gather_rx_stats(nic_rx_stats, &nic_dev->rxqs[i]); in gather_nic_stats()
120 gather_tx_stats(nic_tx_stats, &nic_dev->txqs[i]); in gather_nic_stats()
129 static int create_txqs(struct hinic_dev *nic_dev) in create_txqs() argument
131 int err, i, j, num_txqs = hinic_hwdev_num_qps(nic_dev->hwdev); in create_txqs()
132 struct net_device *netdev = nic_dev->netdev; in create_txqs()
134 if (nic_dev->txqs) in create_txqs()
137 nic_dev->txqs = devm_kcalloc(&netdev->dev, num_txqs, in create_txqs()
138 sizeof(*nic_dev->txqs), GFP_KERNEL); in create_txqs()
139 if (!nic_dev->txqs) in create_txqs()
142 hinic_sq_dbgfs_init(nic_dev); in create_txqs()
145 struct hinic_sq *sq = hinic_hwdev_get_sq(nic_dev->hwdev, i); in create_txqs()
147 err = hinic_init_txq(&nic_dev->txqs[i], sq, netdev); in create_txqs()
149 netif_err(nic_dev, drv, netdev, in create_txqs()
154 err = hinic_sq_debug_add(nic_dev, i); in create_txqs()
156 netif_err(nic_dev, drv, netdev, in create_txqs()
165 hinic_clean_txq(&nic_dev->txqs[i]); in create_txqs()
168 hinic_sq_debug_rem(nic_dev->txqs[j].sq); in create_txqs()
169 hinic_clean_txq(&nic_dev->txqs[j]); in create_txqs()
172 hinic_sq_dbgfs_uninit(nic_dev); in create_txqs()
174 devm_kfree(&netdev->dev, nic_dev->txqs); in create_txqs()
178 static void enable_txqs_napi(struct hinic_dev *nic_dev) in enable_txqs_napi() argument
180 int num_txqs = hinic_hwdev_num_qps(nic_dev->hwdev); in enable_txqs_napi()
184 napi_enable(&nic_dev->txqs[i].napi); in enable_txqs_napi()
187 static void disable_txqs_napi(struct hinic_dev *nic_dev) in disable_txqs_napi() argument
189 int num_txqs = hinic_hwdev_num_qps(nic_dev->hwdev); in disable_txqs_napi()
193 napi_disable(&nic_dev->txqs[i].napi); in disable_txqs_napi()
200 static void free_txqs(struct hinic_dev *nic_dev) in free_txqs() argument
202 int i, num_txqs = hinic_hwdev_num_qps(nic_dev->hwdev); in free_txqs()
203 struct net_device *netdev = nic_dev->netdev; in free_txqs()
205 if (!nic_dev->txqs) in free_txqs()
209 hinic_sq_debug_rem(nic_dev->txqs[i].sq); in free_txqs()
210 hinic_clean_txq(&nic_dev->txqs[i]); in free_txqs()
213 hinic_sq_dbgfs_uninit(nic_dev); in free_txqs()
215 devm_kfree(&netdev->dev, nic_dev->txqs); in free_txqs()
216 nic_dev->txqs = NULL; in free_txqs()
225 static int create_rxqs(struct hinic_dev *nic_dev) in create_rxqs() argument
227 int err, i, j, num_rxqs = hinic_hwdev_num_qps(nic_dev->hwdev); in create_rxqs()
228 struct net_device *netdev = nic_dev->netdev; in create_rxqs()
230 if (nic_dev->rxqs) in create_rxqs()
233 nic_dev->rxqs = devm_kcalloc(&netdev->dev, num_rxqs, in create_rxqs()
234 sizeof(*nic_dev->rxqs), GFP_KERNEL); in create_rxqs()
235 if (!nic_dev->rxqs) in create_rxqs()
238 hinic_rq_dbgfs_init(nic_dev); in create_rxqs()
241 struct hinic_rq *rq = hinic_hwdev_get_rq(nic_dev->hwdev, i); in create_rxqs()
243 err = hinic_init_rxq(&nic_dev->rxqs[i], rq, netdev); in create_rxqs()
245 netif_err(nic_dev, drv, netdev, in create_rxqs()
250 err = hinic_rq_debug_add(nic_dev, i); in create_rxqs()
252 netif_err(nic_dev, drv, netdev, in create_rxqs()
261 hinic_clean_rxq(&nic_dev->rxqs[i]); in create_rxqs()
264 hinic_rq_debug_rem(nic_dev->rxqs[j].rq); in create_rxqs()
265 hinic_clean_rxq(&nic_dev->rxqs[j]); in create_rxqs()
268 hinic_rq_dbgfs_uninit(nic_dev); in create_rxqs()
270 devm_kfree(&netdev->dev, nic_dev->rxqs); in create_rxqs()
278 static void free_rxqs(struct hinic_dev *nic_dev) in free_rxqs() argument
280 int i, num_rxqs = hinic_hwdev_num_qps(nic_dev->hwdev); in free_rxqs()
281 struct net_device *netdev = nic_dev->netdev; in free_rxqs()
283 if (!nic_dev->rxqs) in free_rxqs()
287 hinic_rq_debug_rem(nic_dev->rxqs[i].rq); in free_rxqs()
288 hinic_clean_rxq(&nic_dev->rxqs[i]); in free_rxqs()
291 hinic_rq_dbgfs_uninit(nic_dev); in free_rxqs()
293 devm_kfree(&netdev->dev, nic_dev->rxqs); in free_rxqs()
294 nic_dev->rxqs = NULL; in free_rxqs()
297 static int hinic_configure_max_qnum(struct hinic_dev *nic_dev) in hinic_configure_max_qnum() argument
299 return hinic_set_max_qnum(nic_dev, nic_dev->hwdev->nic_cap.max_qps); in hinic_configure_max_qnum()
302 static int hinic_rss_init(struct hinic_dev *nic_dev) in hinic_rss_init() argument
305 u8 tmpl_idx = nic_dev->rss_tmpl_idx; in hinic_rss_init()
315 indir_tbl[i] = ethtool_rxfh_indir_default(i, nic_dev->num_rss); in hinic_rss_init()
317 err = hinic_rss_set_template_tbl(nic_dev, tmpl_idx, default_rss_key); in hinic_rss_init()
321 err = hinic_rss_set_indir_tbl(nic_dev, tmpl_idx, indir_tbl); in hinic_rss_init()
325 err = hinic_set_rss_type(nic_dev, tmpl_idx, nic_dev->rss_type); in hinic_rss_init()
329 err = hinic_rss_set_hash_engine(nic_dev, tmpl_idx, in hinic_rss_init()
330 nic_dev->rss_hash_engine); in hinic_rss_init()
334 err = hinic_rss_cfg(nic_dev, 1, tmpl_idx); in hinic_rss_init()
343 static void hinic_rss_deinit(struct hinic_dev *nic_dev) in hinic_rss_deinit() argument
345 hinic_rss_cfg(nic_dev, 0, nic_dev->rss_tmpl_idx); in hinic_rss_deinit()
348 static void hinic_init_rss_parameters(struct hinic_dev *nic_dev) in hinic_init_rss_parameters() argument
350 nic_dev->rss_hash_engine = HINIC_RSS_HASH_ENGINE_TYPE_XOR; in hinic_init_rss_parameters()
351 nic_dev->rss_type.tcp_ipv6_ext = 1; in hinic_init_rss_parameters()
352 nic_dev->rss_type.ipv6_ext = 1; in hinic_init_rss_parameters()
353 nic_dev->rss_type.tcp_ipv6 = 1; in hinic_init_rss_parameters()
354 nic_dev->rss_type.ipv6 = 1; in hinic_init_rss_parameters()
355 nic_dev->rss_type.tcp_ipv4 = 1; in hinic_init_rss_parameters()
356 nic_dev->rss_type.ipv4 = 1; in hinic_init_rss_parameters()
357 nic_dev->rss_type.udp_ipv6 = 1; in hinic_init_rss_parameters()
358 nic_dev->rss_type.udp_ipv4 = 1; in hinic_init_rss_parameters()
361 static void hinic_enable_rss(struct hinic_dev *nic_dev) in hinic_enable_rss() argument
363 struct net_device *netdev = nic_dev->netdev; in hinic_enable_rss()
364 struct hinic_hwdev *hwdev = nic_dev->hwdev; in hinic_enable_rss()
370 if (nic_dev->max_qps <= 1) { in hinic_enable_rss()
371 nic_dev->flags &= ~HINIC_RSS_ENABLE; in hinic_enable_rss()
372 nic_dev->rss_limit = nic_dev->max_qps; in hinic_enable_rss()
373 nic_dev->num_qps = nic_dev->max_qps; in hinic_enable_rss()
374 nic_dev->num_rss = nic_dev->max_qps; in hinic_enable_rss()
379 err = hinic_rss_template_alloc(nic_dev, &nic_dev->rss_tmpl_idx); in hinic_enable_rss()
381 netif_err(nic_dev, drv, netdev, in hinic_enable_rss()
383 nic_dev->flags &= ~HINIC_RSS_ENABLE; in hinic_enable_rss()
384 nic_dev->max_qps = 1; in hinic_enable_rss()
385 nic_dev->rss_limit = nic_dev->max_qps; in hinic_enable_rss()
386 nic_dev->num_qps = nic_dev->max_qps; in hinic_enable_rss()
387 nic_dev->num_rss = nic_dev->max_qps; in hinic_enable_rss()
392 nic_dev->flags |= HINIC_RSS_ENABLE; in hinic_enable_rss()
403 nic_dev->num_qps = hinic_hwdev_num_qps(hwdev); in hinic_enable_rss()
404 nic_dev->num_qps = min_t(u16, nic_dev->num_qps, num_cpus); in hinic_enable_rss()
406 nic_dev->rss_limit = nic_dev->num_qps; in hinic_enable_rss()
407 nic_dev->num_rss = nic_dev->num_qps; in hinic_enable_rss()
409 hinic_init_rss_parameters(nic_dev); in hinic_enable_rss()
410 err = hinic_rss_init(nic_dev); in hinic_enable_rss()
412 netif_err(nic_dev, drv, netdev, "Failed to init rss\n"); in hinic_enable_rss()
417 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_open() local
421 if (!(nic_dev->flags & HINIC_INTF_UP)) { in hinic_open()
422 err = hinic_hwdev_ifup(nic_dev->hwdev, nic_dev->sq_depth, in hinic_open()
423 nic_dev->rq_depth); in hinic_open()
425 netif_err(nic_dev, drv, netdev, in hinic_open()
431 err = create_txqs(nic_dev); in hinic_open()
433 netif_err(nic_dev, drv, netdev, in hinic_open()
438 enable_txqs_napi(nic_dev); in hinic_open()
440 err = create_rxqs(nic_dev); in hinic_open()
442 netif_err(nic_dev, drv, netdev, in hinic_open()
447 hinic_enable_rss(nic_dev); in hinic_open()
449 err = hinic_configure_max_qnum(nic_dev); in hinic_open()
451 netif_err(nic_dev, drv, nic_dev->netdev, in hinic_open()
456 netif_set_real_num_tx_queues(netdev, nic_dev->num_qps); in hinic_open()
457 netif_set_real_num_rx_queues(netdev, nic_dev->num_qps); in hinic_open()
459 err = hinic_port_set_state(nic_dev, HINIC_PORT_ENABLE); in hinic_open()
461 netif_err(nic_dev, drv, netdev, in hinic_open()
466 err = hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_ENABLE); in hinic_open()
468 netif_err(nic_dev, drv, netdev, in hinic_open()
473 down(&nic_dev->mgmt_lock); in hinic_open()
475 err = hinic_port_link_state(nic_dev, &link_state); in hinic_open()
477 netif_err(nic_dev, drv, netdev, "Failed to get link state\n"); in hinic_open()
481 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) in hinic_open()
482 hinic_notify_all_vfs_link_changed(nic_dev->hwdev, link_state); in hinic_open()
485 nic_dev->flags |= HINIC_LINK_UP; in hinic_open()
486 nic_dev->cable_unplugged = false; in hinic_open()
487 nic_dev->module_unrecognized = false; in hinic_open()
490 nic_dev->flags |= HINIC_INTF_UP; in hinic_open()
492 if ((nic_dev->flags & (HINIC_LINK_UP | HINIC_INTF_UP)) == in hinic_open()
494 netif_info(nic_dev, drv, netdev, "link + intf UP\n"); in hinic_open()
499 up(&nic_dev->mgmt_lock); in hinic_open()
501 netif_info(nic_dev, drv, netdev, "HINIC_INTF is UP\n"); in hinic_open()
505 up(&nic_dev->mgmt_lock); in hinic_open()
506 ret = hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_DISABLE); in hinic_open()
508 netif_warn(nic_dev, drv, netdev, in hinic_open()
512 ret = hinic_port_set_state(nic_dev, HINIC_PORT_DISABLE); in hinic_open()
514 netif_warn(nic_dev, drv, netdev, in hinic_open()
517 free_rxqs(nic_dev); in hinic_open()
518 if (nic_dev->flags & HINIC_RSS_ENABLE) { in hinic_open()
519 hinic_rss_deinit(nic_dev); in hinic_open()
520 hinic_rss_template_free(nic_dev, nic_dev->rss_tmpl_idx); in hinic_open()
524 disable_txqs_napi(nic_dev); in hinic_open()
525 free_txqs(nic_dev); in hinic_open()
528 if (!(nic_dev->flags & HINIC_INTF_UP)) in hinic_open()
529 hinic_hwdev_ifdown(nic_dev->hwdev); in hinic_open()
535 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_close() local
539 disable_txqs_napi(nic_dev); in hinic_close()
541 down(&nic_dev->mgmt_lock); in hinic_close()
543 flags = nic_dev->flags; in hinic_close()
544 nic_dev->flags &= ~HINIC_INTF_UP; in hinic_close()
549 up(&nic_dev->mgmt_lock); in hinic_close()
551 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) in hinic_close()
552 hinic_notify_all_vfs_link_changed(nic_dev->hwdev, 0); in hinic_close()
554 hinic_port_set_state(nic_dev, HINIC_PORT_DISABLE); in hinic_close()
556 hinic_port_set_func_state(nic_dev, HINIC_FUNC_PORT_DISABLE); in hinic_close()
558 if (nic_dev->flags & HINIC_RSS_ENABLE) { in hinic_close()
559 hinic_rss_deinit(nic_dev); in hinic_close()
560 hinic_rss_template_free(nic_dev, nic_dev->rss_tmpl_idx); in hinic_close()
563 free_rxqs(nic_dev); in hinic_close()
564 free_txqs(nic_dev); in hinic_close()
567 hinic_hwdev_ifdown(nic_dev->hwdev); in hinic_close()
569 netif_info(nic_dev, drv, netdev, "HINIC_INTF is DOWN\n"); in hinic_close()
575 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_change_mtu() local
578 netif_info(nic_dev, drv, netdev, "set_mtu = %d\n", new_mtu); in hinic_change_mtu()
580 err = hinic_port_set_mtu(nic_dev, new_mtu); in hinic_change_mtu()
582 netif_err(nic_dev, drv, netdev, "Failed to set port mtu\n"); in hinic_change_mtu()
598 struct hinic_dev *nic_dev = netdev_priv(netdev); in change_mac_addr() local
605 netif_info(nic_dev, drv, netdev, "change mac addr = %02x %02x %02x %02x %02x %02x\n", in change_mac_addr()
608 down(&nic_dev->mgmt_lock); in change_mac_addr()
611 err = hinic_port_del_mac(nic_dev, netdev->dev_addr, vid); in change_mac_addr()
613 netif_err(nic_dev, drv, netdev, in change_mac_addr()
618 err = hinic_port_add_mac(nic_dev, addr, vid); in change_mac_addr()
620 netif_err(nic_dev, drv, netdev, "Failed to add mac\n"); in change_mac_addr()
624 vid = find_next_bit(nic_dev->vlan_bitmap, VLAN_N_VID, vid + 1); in change_mac_addr()
627 up(&nic_dev->mgmt_lock); in change_mac_addr()
655 struct hinic_dev *nic_dev = netdev_priv(netdev); in add_mac_addr() local
659 netif_info(nic_dev, drv, netdev, "set mac addr = %02x %02x %02x %02x %02x %02x\n", in add_mac_addr()
662 down(&nic_dev->mgmt_lock); in add_mac_addr()
665 err = hinic_port_add_mac(nic_dev, addr, vid); in add_mac_addr()
667 netif_err(nic_dev, drv, netdev, "Failed to add mac\n"); in add_mac_addr()
671 vid = find_next_bit(nic_dev->vlan_bitmap, VLAN_N_VID, vid + 1); in add_mac_addr()
674 up(&nic_dev->mgmt_lock); in add_mac_addr()
687 struct hinic_dev *nic_dev = netdev_priv(netdev); in remove_mac_addr() local
694 netif_info(nic_dev, drv, netdev, "remove mac addr = %02x %02x %02x %02x %02x %02x\n", in remove_mac_addr()
697 down(&nic_dev->mgmt_lock); in remove_mac_addr()
700 err = hinic_port_del_mac(nic_dev, addr, vid); in remove_mac_addr()
702 netif_err(nic_dev, drv, netdev, in remove_mac_addr()
707 vid = find_next_bit(nic_dev->vlan_bitmap, VLAN_N_VID, vid + 1); in remove_mac_addr()
710 up(&nic_dev->mgmt_lock); in remove_mac_addr()
717 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_vlan_rx_add_vid() local
720 netif_info(nic_dev, drv, netdev, "add vid = %d\n", vid); in hinic_vlan_rx_add_vid()
722 down(&nic_dev->mgmt_lock); in hinic_vlan_rx_add_vid()
724 err = hinic_port_add_vlan(nic_dev, vid); in hinic_vlan_rx_add_vid()
726 netif_err(nic_dev, drv, netdev, "Failed to add vlan\n"); in hinic_vlan_rx_add_vid()
730 err = hinic_port_add_mac(nic_dev, netdev->dev_addr, vid); in hinic_vlan_rx_add_vid()
732 netif_err(nic_dev, drv, netdev, "Failed to set mac\n"); in hinic_vlan_rx_add_vid()
736 bitmap_set(nic_dev->vlan_bitmap, vid, 1); in hinic_vlan_rx_add_vid()
738 up(&nic_dev->mgmt_lock); in hinic_vlan_rx_add_vid()
742 ret = hinic_port_del_vlan(nic_dev, vid); in hinic_vlan_rx_add_vid()
744 netif_err(nic_dev, drv, netdev, in hinic_vlan_rx_add_vid()
748 up(&nic_dev->mgmt_lock); in hinic_vlan_rx_add_vid()
755 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_vlan_rx_kill_vid() local
758 netif_info(nic_dev, drv, netdev, "remove vid = %d\n", vid); in hinic_vlan_rx_kill_vid()
760 down(&nic_dev->mgmt_lock); in hinic_vlan_rx_kill_vid()
762 err = hinic_port_del_vlan(nic_dev, vid); in hinic_vlan_rx_kill_vid()
764 netif_err(nic_dev, drv, netdev, "Failed to delete vlan\n"); in hinic_vlan_rx_kill_vid()
768 bitmap_clear(nic_dev->vlan_bitmap, vid, 1); in hinic_vlan_rx_kill_vid()
770 up(&nic_dev->mgmt_lock); in hinic_vlan_rx_kill_vid()
774 up(&nic_dev->mgmt_lock); in hinic_vlan_rx_kill_vid()
781 struct hinic_dev *nic_dev = rx_mode_work_to_nic_dev(rx_mode_work); in set_rx_mode() local
783 hinic_port_set_rx_mode(nic_dev, rx_mode_work->rx_mode); in set_rx_mode()
785 __dev_uc_sync(nic_dev->netdev, add_mac_addr, remove_mac_addr); in set_rx_mode()
786 __dev_mc_sync(nic_dev->netdev, add_mac_addr, remove_mac_addr); in set_rx_mode()
791 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_set_rx_mode() local
795 rx_mode_work = &nic_dev->rx_mode_work; in hinic_set_rx_mode()
802 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) in hinic_set_rx_mode()
810 queue_work(nic_dev->workq, &rx_mode_work->work); in hinic_set_rx_mode()
815 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_tx_timeout() local
820 num_sqs = hinic_hwdev_num_qps(nic_dev->hwdev); in hinic_tx_timeout()
822 netif_err(nic_dev, drv, netdev, "Tx timeout\n"); in hinic_tx_timeout()
828 sq = hinic_hwdev_get_sq(nic_dev->hwdev, q_id); in hinic_tx_timeout()
832 netif_err(nic_dev, drv, netdev, "Txq%d: sw_pi: %d, hw_ci: %d, sw_ci: %d, napi->state: 0x%lx\n", in hinic_tx_timeout()
834 nic_dev->txqs[q_id].napi.state); in hinic_tx_timeout()
841 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_get_stats64() local
845 if (nic_dev->flags & HINIC_INTF_UP) in hinic_get_stats64()
846 gather_nic_stats(nic_dev, &nic_rx_stats, &nic_tx_stats); in hinic_get_stats64()
860 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_set_features() local
862 return set_features(nic_dev, nic_dev->netdev->features, in hinic_set_features()
869 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_fix_features() local
873 netif_info(nic_dev, drv, netdev, "disabling LRO as RXCSUM is off\n"); in hinic_fix_features()
936 static void hinic_refresh_nic_cfg(struct hinic_dev *nic_dev) in hinic_refresh_nic_cfg() argument
938 struct hinic_nic_cfg *nic_cfg = &nic_dev->hwdev->func_to_io.nic_cfg; in hinic_refresh_nic_cfg()
942 if (hinic_port_get_cap(nic_dev, &port_cap)) in hinic_refresh_nic_cfg()
951 hinic_set_hw_pause_info(nic_dev->hwdev, &pause_info); in hinic_refresh_nic_cfg()
968 struct hinic_dev *nic_dev = handle; in link_status_event_handler() local
973 down(&nic_dev->mgmt_lock); in link_status_event_handler()
975 nic_dev->flags |= HINIC_LINK_UP; in link_status_event_handler()
976 nic_dev->cable_unplugged = false; in link_status_event_handler()
977 nic_dev->module_unrecognized = false; in link_status_event_handler()
979 if ((nic_dev->flags & (HINIC_LINK_UP | HINIC_INTF_UP)) == in link_status_event_handler()
981 netif_carrier_on(nic_dev->netdev); in link_status_event_handler()
982 netif_tx_wake_all_queues(nic_dev->netdev); in link_status_event_handler()
985 up(&nic_dev->mgmt_lock); in link_status_event_handler()
987 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) in link_status_event_handler()
988 hinic_refresh_nic_cfg(nic_dev); in link_status_event_handler()
990 netif_info(nic_dev, drv, nic_dev->netdev, "HINIC_Link is UP\n"); in link_status_event_handler()
992 down(&nic_dev->mgmt_lock); in link_status_event_handler()
994 nic_dev->flags &= ~HINIC_LINK_UP; in link_status_event_handler()
996 netif_carrier_off(nic_dev->netdev); in link_status_event_handler()
997 netif_tx_disable(nic_dev->netdev); in link_status_event_handler()
999 up(&nic_dev->mgmt_lock); in link_status_event_handler()
1001 netif_info(nic_dev, drv, nic_dev->netdev, "HINIC_Link is DOWN\n"); in link_status_event_handler()
1004 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) in link_status_event_handler()
1005 hinic_notify_all_vfs_link_changed(nic_dev->hwdev, in link_status_event_handler()
1019 struct hinic_dev *nic_dev = handle; in cable_plug_event() local
1021 nic_dev->cable_unplugged = plug_event->plugged ? false : true; in cable_plug_event()
1033 struct hinic_dev *nic_dev = handle; in link_err_event() local
1036 netif_info(nic_dev, link, nic_dev->netdev, in link_err_event()
1040 nic_dev->module_unrecognized = true; in link_err_event()
1047 static int set_features(struct hinic_dev *nic_dev, in set_features() argument
1058 ret = hinic_port_set_tso(nic_dev, (features & NETIF_F_TSO) ? in set_features()
1067 ret = hinic_set_rx_csum_offload(nic_dev, csum_en); in set_features()
1075 ret = hinic_set_rx_lro_state(nic_dev, in set_features()
1086 ret = hinic_set_rx_vlan_offload(nic_dev, in set_features()
1096 nic_dev->netdev->features = features ^ failed_features; in set_features()
1103 static int hinic_init_intr_coalesce(struct hinic_dev *nic_dev) in hinic_init_intr_coalesce() argument
1108 size = sizeof(struct hinic_intr_coal_info) * nic_dev->max_qps; in hinic_init_intr_coalesce()
1109 nic_dev->rx_intr_coalesce = kzalloc(size, GFP_KERNEL); in hinic_init_intr_coalesce()
1110 if (!nic_dev->rx_intr_coalesce) in hinic_init_intr_coalesce()
1112 nic_dev->tx_intr_coalesce = kzalloc(size, GFP_KERNEL); in hinic_init_intr_coalesce()
1113 if (!nic_dev->tx_intr_coalesce) { in hinic_init_intr_coalesce()
1114 kfree(nic_dev->rx_intr_coalesce); in hinic_init_intr_coalesce()
1118 for (i = 0; i < nic_dev->max_qps; i++) { in hinic_init_intr_coalesce()
1119 nic_dev->rx_intr_coalesce[i].pending_limt = in hinic_init_intr_coalesce()
1121 nic_dev->rx_intr_coalesce[i].coalesce_timer_cfg = in hinic_init_intr_coalesce()
1123 nic_dev->rx_intr_coalesce[i].resend_timer_cfg = in hinic_init_intr_coalesce()
1125 nic_dev->tx_intr_coalesce[i].pending_limt = in hinic_init_intr_coalesce()
1127 nic_dev->tx_intr_coalesce[i].coalesce_timer_cfg = in hinic_init_intr_coalesce()
1129 nic_dev->tx_intr_coalesce[i].resend_timer_cfg = in hinic_init_intr_coalesce()
1136 static void hinic_free_intr_coalesce(struct hinic_dev *nic_dev) in hinic_free_intr_coalesce() argument
1138 kfree(nic_dev->tx_intr_coalesce); in hinic_free_intr_coalesce()
1139 kfree(nic_dev->rx_intr_coalesce); in hinic_free_intr_coalesce()
1151 struct hinic_dev *nic_dev; in nic_dev_init() local
1178 netdev = alloc_etherdev_mq(sizeof(*nic_dev), num_qps); in nic_dev_init()
1192 nic_dev = netdev_priv(netdev); in nic_dev_init()
1193 nic_dev->netdev = netdev; in nic_dev_init()
1194 nic_dev->hwdev = hwdev; in nic_dev_init()
1195 nic_dev->msg_enable = MSG_ENABLE_DEFAULT; in nic_dev_init()
1196 nic_dev->flags = 0; in nic_dev_init()
1197 nic_dev->txqs = NULL; in nic_dev_init()
1198 nic_dev->rxqs = NULL; in nic_dev_init()
1199 nic_dev->tx_weight = tx_weight; in nic_dev_init()
1200 nic_dev->rx_weight = rx_weight; in nic_dev_init()
1201 nic_dev->sq_depth = HINIC_SQ_DEPTH; in nic_dev_init()
1202 nic_dev->rq_depth = HINIC_RQ_DEPTH; in nic_dev_init()
1203 nic_dev->sriov_info.hwdev = hwdev; in nic_dev_init()
1204 nic_dev->sriov_info.pdev = pdev; in nic_dev_init()
1205 nic_dev->max_qps = num_qps; in nic_dev_init()
1206 nic_dev->devlink = devlink; in nic_dev_init()
1210 sema_init(&nic_dev->mgmt_lock, 1); in nic_dev_init()
1212 nic_dev->vlan_bitmap = devm_bitmap_zalloc(&pdev->dev, VLAN_N_VID, in nic_dev_init()
1214 if (!nic_dev->vlan_bitmap) { in nic_dev_init()
1219 nic_dev->workq = create_singlethread_workqueue(HINIC_WQ_NAME); in nic_dev_init()
1220 if (!nic_dev->workq) { in nic_dev_init()
1227 err = hinic_port_get_mac(nic_dev, addr); in nic_dev_init()
1235 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) { in nic_dev_init()
1246 err = hinic_port_add_mac(nic_dev, netdev->dev_addr, 0); in nic_dev_init()
1252 err = hinic_port_set_mtu(nic_dev, netdev->mtu); in nic_dev_init()
1258 rx_mode_work = &nic_dev->rx_mode_work; in nic_dev_init()
1265 hinic_hwdev_cb_register(nic_dev->hwdev, HINIC_MGMT_MSG_CMD_LINK_STATUS, in nic_dev_init()
1266 nic_dev, link_status_event_handler); in nic_dev_init()
1267 hinic_hwdev_cb_register(nic_dev->hwdev, in nic_dev_init()
1269 nic_dev, cable_plug_event); in nic_dev_init()
1270 hinic_hwdev_cb_register(nic_dev->hwdev, in nic_dev_init()
1272 nic_dev, link_err_event); in nic_dev_init()
1274 err = set_features(nic_dev, 0, nic_dev->netdev->features, true); in nic_dev_init()
1279 err = hinic_dcb_set_pfc(nic_dev->hwdev, 0, 0); in nic_dev_init()
1285 err = hinic_init_intr_coalesce(nic_dev); in nic_dev_init()
1291 hinic_dbg_init(nic_dev); in nic_dev_init()
1293 hinic_func_tbl_dbgfs_init(nic_dev); in nic_dev_init()
1295 err = hinic_func_table_debug_add(nic_dev); in nic_dev_init()
1310 hinic_func_table_debug_rem(nic_dev); in nic_dev_init()
1312 hinic_func_tbl_dbgfs_uninit(nic_dev); in nic_dev_init()
1313 hinic_dbg_uninit(nic_dev); in nic_dev_init()
1314 hinic_free_intr_coalesce(nic_dev); in nic_dev_init()
1318 hinic_hwdev_cb_unregister(nic_dev->hwdev, in nic_dev_init()
1320 hinic_hwdev_cb_unregister(nic_dev->hwdev, in nic_dev_init()
1322 hinic_hwdev_cb_unregister(nic_dev->hwdev, in nic_dev_init()
1327 hinic_port_del_mac(nic_dev, netdev->dev_addr, 0); in nic_dev_init()
1331 destroy_workqueue(nic_dev->workq); in nic_dev_init()
1383 static void wait_sriov_cfg_complete(struct hinic_dev *nic_dev) in wait_sriov_cfg_complete() argument
1385 struct hinic_sriov_info *sriov_info = &nic_dev->sriov_info; in wait_sriov_cfg_complete()
1404 struct hinic_dev *nic_dev = netdev_priv(netdev); in hinic_remove() local
1405 struct devlink *devlink = nic_dev->devlink; in hinic_remove()
1408 if (!HINIC_IS_VF(nic_dev->hwdev->hwif)) { in hinic_remove()
1409 wait_sriov_cfg_complete(nic_dev); in hinic_remove()
1415 hinic_func_table_debug_rem(nic_dev); in hinic_remove()
1417 hinic_func_tbl_dbgfs_uninit(nic_dev); in hinic_remove()
1419 hinic_dbg_uninit(nic_dev); in hinic_remove()
1421 hinic_free_intr_coalesce(nic_dev); in hinic_remove()
1423 hinic_port_del_mac(nic_dev, netdev->dev_addr, 0); in hinic_remove()
1425 hinic_hwdev_cb_unregister(nic_dev->hwdev, in hinic_remove()
1427 hinic_hwdev_cb_unregister(nic_dev->hwdev, in hinic_remove()
1429 hinic_hwdev_cb_unregister(nic_dev->hwdev, in hinic_remove()
1432 rx_mode_work = &nic_dev->rx_mode_work; in hinic_remove()
1437 destroy_workqueue(nic_dev->workq); in hinic_remove()
1439 hinic_free_hwdev(nic_dev->hwdev); in hinic_remove()