Lines Matching full:self
43 static void aq_nic_update_ndev_stats(struct aq_nic_s *self);
45 static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues) in aq_nic_rss_init() argument
54 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_rss_init()
69 static void aq_nic_cfg_update_num_vecs(struct aq_nic_s *self) in aq_nic_cfg_update_num_vecs() argument
71 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_cfg_update_num_vecs()
75 if (self->irqvecs > AQ_HW_SERVICE_IRQS) in aq_nic_cfg_update_num_vecs()
76 cfg->vecs = min(cfg->vecs, self->irqvecs - AQ_HW_SERVICE_IRQS); in aq_nic_cfg_update_num_vecs()
80 if (ATL_HW_IS_CHIP_FEATURE(self->aq_hw, ANTIGUA)) { in aq_nic_cfg_update_num_vecs()
92 aq_nic_rss_init(self, cfg->num_rss_queues); in aq_nic_cfg_update_num_vecs()
96 void aq_nic_cfg_start(struct aq_nic_s *self) in aq_nic_cfg_start() argument
98 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_cfg_start()
126 aq_nic_cfg_update_num_vecs(self); in aq_nic_cfg_start()
128 cfg->irq_type = aq_pci_func_get_irq_type(self); in aq_nic_cfg_start()
141 if (AQ_HW_SERVICE_IRQS > 0 && cfg->vecs + 1 <= self->irqvecs) in aq_nic_cfg_start()
156 static int aq_nic_update_link_status(struct aq_nic_s *self) in aq_nic_update_link_status() argument
158 int err = self->aq_fw_ops->update_link_status(self->aq_hw); in aq_nic_update_link_status()
164 if (self->aq_fw_ops->get_flow_control) in aq_nic_update_link_status()
165 self->aq_fw_ops->get_flow_control(self->aq_hw, &fc); in aq_nic_update_link_status()
166 self->aq_nic_cfg.fc.cur = fc; in aq_nic_update_link_status()
168 if (self->link_status.mbps != self->aq_hw->aq_link_status.mbps) { in aq_nic_update_link_status()
169 netdev_info(self->ndev, "%s: link change old %d new %d\n", in aq_nic_update_link_status()
170 AQ_CFG_DRV_NAME, self->link_status.mbps, in aq_nic_update_link_status()
171 self->aq_hw->aq_link_status.mbps); in aq_nic_update_link_status()
172 aq_nic_update_interrupt_moderation_settings(self); in aq_nic_update_link_status()
174 if (self->aq_ptp) { in aq_nic_update_link_status()
175 aq_ptp_clock_init(self); in aq_nic_update_link_status()
176 aq_ptp_tm_offset_set(self, in aq_nic_update_link_status()
177 self->aq_hw->aq_link_status.mbps); in aq_nic_update_link_status()
178 aq_ptp_link_change(self); in aq_nic_update_link_status()
185 if (self->aq_hw_ops->hw_set_fc) in aq_nic_update_link_status()
186 self->aq_hw_ops->hw_set_fc(self->aq_hw, fc, 0); in aq_nic_update_link_status()
189 self->link_status = self->aq_hw->aq_link_status; in aq_nic_update_link_status()
190 if (!netif_carrier_ok(self->ndev) && self->link_status.mbps) { in aq_nic_update_link_status()
191 aq_utils_obj_set(&self->flags, in aq_nic_update_link_status()
193 aq_utils_obj_clear(&self->flags, in aq_nic_update_link_status()
195 netif_carrier_on(self->ndev); in aq_nic_update_link_status()
197 aq_macsec_enable(self); in aq_nic_update_link_status()
199 if (self->aq_hw_ops->hw_tc_rate_limit_set) in aq_nic_update_link_status()
200 self->aq_hw_ops->hw_tc_rate_limit_set(self->aq_hw); in aq_nic_update_link_status()
202 netif_tx_wake_all_queues(self->ndev); in aq_nic_update_link_status()
204 if (netif_carrier_ok(self->ndev) && !self->link_status.mbps) { in aq_nic_update_link_status()
205 netif_carrier_off(self->ndev); in aq_nic_update_link_status()
206 netif_tx_disable(self->ndev); in aq_nic_update_link_status()
207 aq_utils_obj_set(&self->flags, AQ_NIC_LINK_DOWN); in aq_nic_update_link_status()
215 struct aq_nic_s *self = private; in aq_linkstate_threaded_isr() local
217 if (!self) in aq_linkstate_threaded_isr()
220 aq_nic_update_link_status(self); in aq_linkstate_threaded_isr()
222 self->aq_hw_ops->hw_irq_enable(self->aq_hw, in aq_linkstate_threaded_isr()
223 BIT(self->aq_nic_cfg.link_irq_vec)); in aq_linkstate_threaded_isr()
230 struct aq_nic_s *self = container_of(work, struct aq_nic_s, in aq_nic_service_task() local
234 aq_ptp_service_task(self); in aq_nic_service_task()
236 if (aq_utils_obj_test(&self->flags, AQ_NIC_FLAGS_IS_NOT_READY)) in aq_nic_service_task()
239 err = aq_nic_update_link_status(self); in aq_nic_service_task()
244 aq_macsec_work(self); in aq_nic_service_task()
247 mutex_lock(&self->fwreq_mutex); in aq_nic_service_task()
248 if (self->aq_fw_ops->update_stats) in aq_nic_service_task()
249 self->aq_fw_ops->update_stats(self->aq_hw); in aq_nic_service_task()
250 mutex_unlock(&self->fwreq_mutex); in aq_nic_service_task()
252 aq_nic_update_ndev_stats(self); in aq_nic_service_task()
257 struct aq_nic_s *self = from_timer(self, t, service_timer); in aq_nic_service_timer_cb() local
259 mod_timer(&self->service_timer, in aq_nic_service_timer_cb()
262 aq_ndev_schedule_work(&self->service_task); in aq_nic_service_timer_cb()
267 struct aq_nic_s *self = from_timer(self, t, polling_timer); in aq_nic_polling_timer_cb() local
270 for (i = 0U; self->aq_vecs > i; ++i) in aq_nic_polling_timer_cb()
271 aq_vec_isr(i, (void *)self->aq_vec[i]); in aq_nic_polling_timer_cb()
273 mod_timer(&self->polling_timer, jiffies + in aq_nic_polling_timer_cb()
277 static int aq_nic_hw_prepare(struct aq_nic_s *self) in aq_nic_hw_prepare() argument
281 err = self->aq_hw_ops->hw_soft_reset(self->aq_hw); in aq_nic_hw_prepare()
285 err = self->aq_hw_ops->hw_prepare(self->aq_hw, &self->aq_fw_ops); in aq_nic_hw_prepare()
299 int aq_nic_ndev_register(struct aq_nic_s *self) in aq_nic_ndev_register() argument
304 if (!self->ndev) { in aq_nic_ndev_register()
309 err = aq_nic_hw_prepare(self); in aq_nic_ndev_register()
314 aq_macsec_init(self); in aq_nic_ndev_register()
317 if (platform_get_ethdev_address(&self->pdev->dev, self->ndev) != 0) { in aq_nic_ndev_register()
319 mutex_lock(&self->fwreq_mutex); in aq_nic_ndev_register()
320 err = self->aq_fw_ops->get_mac_permanent(self->aq_hw, addr); in aq_nic_ndev_register()
321 mutex_unlock(&self->fwreq_mutex); in aq_nic_ndev_register()
328 eth_hw_addr_set(self->ndev, addr); in aq_nic_ndev_register()
330 netdev_warn(self->ndev, "MAC is invalid, will use random."); in aq_nic_ndev_register()
331 eth_hw_addr_random(self->ndev); in aq_nic_ndev_register()
339 eth_hw_addr_set(self->ndev, mac_addr_permanent); in aq_nic_ndev_register()
343 for (self->aq_vecs = 0; self->aq_vecs < aq_nic_get_cfg(self)->vecs; in aq_nic_ndev_register()
344 self->aq_vecs++) { in aq_nic_ndev_register()
345 self->aq_vec[self->aq_vecs] = in aq_nic_ndev_register()
346 aq_vec_alloc(self, self->aq_vecs, aq_nic_get_cfg(self)); in aq_nic_ndev_register()
347 if (!self->aq_vec[self->aq_vecs]) { in aq_nic_ndev_register()
353 netif_carrier_off(self->ndev); in aq_nic_ndev_register()
355 netif_tx_disable(self->ndev); in aq_nic_ndev_register()
357 err = register_netdev(self->ndev); in aq_nic_ndev_register()
364 aq_macsec_free(self); in aq_nic_ndev_register()
369 void aq_nic_ndev_init(struct aq_nic_s *self) in aq_nic_ndev_init() argument
371 const struct aq_hw_caps_s *aq_hw_caps = self->aq_nic_cfg.aq_hw_caps; in aq_nic_ndev_init()
372 struct aq_nic_cfg_s *aq_nic_cfg = &self->aq_nic_cfg; in aq_nic_ndev_init()
374 self->ndev->hw_features |= aq_hw_caps->hw_features; in aq_nic_ndev_init()
375 self->ndev->features = aq_hw_caps->hw_features; in aq_nic_ndev_init()
376 self->ndev->vlan_features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM | in aq_nic_ndev_init()
379 self->ndev->gso_partial_features = NETIF_F_GSO_UDP_L4; in aq_nic_ndev_init()
380 self->ndev->priv_flags = aq_hw_caps->hw_priv_flags; in aq_nic_ndev_init()
381 self->ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in aq_nic_ndev_init()
383 self->msg_enable = NETIF_MSG_DRV | NETIF_MSG_LINK; in aq_nic_ndev_init()
384 self->ndev->mtu = aq_nic_cfg->mtu - ETH_HLEN; in aq_nic_ndev_init()
385 self->ndev->max_mtu = aq_hw_caps->mtu - ETH_FCS_LEN - ETH_HLEN; in aq_nic_ndev_init()
387 self->ndev->xdp_features = NETDEV_XDP_ACT_BASIC | in aq_nic_ndev_init()
394 void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx, in aq_nic_set_tx_ring() argument
397 self->aq_ring_tx[idx] = ring; in aq_nic_set_tx_ring()
400 struct net_device *aq_nic_get_ndev(struct aq_nic_s *self) in aq_nic_get_ndev() argument
402 return self->ndev; in aq_nic_get_ndev()
405 int aq_nic_init(struct aq_nic_s *self) in aq_nic_init() argument
411 self->power_state = AQ_HW_POWER_STATE_D0; in aq_nic_init()
412 mutex_lock(&self->fwreq_mutex); in aq_nic_init()
413 err = self->aq_hw_ops->hw_reset(self->aq_hw); in aq_nic_init()
414 mutex_unlock(&self->fwreq_mutex); in aq_nic_init()
418 aq_nic_set_downshift(self, self->aq_nic_cfg.downshift_counter); in aq_nic_init()
419 aq_nic_set_media_detect(self, self->aq_nic_cfg.is_media_detect ? in aq_nic_init()
422 err = self->aq_hw_ops->hw_init(self->aq_hw, in aq_nic_init()
423 aq_nic_get_ndev(self)->dev_addr); in aq_nic_init()
427 if (ATL_HW_IS_CHIP_FEATURE(self->aq_hw, ATLANTIC) && in aq_nic_init()
428 self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_TP) { in aq_nic_init()
429 self->aq_hw->phy_id = HW_ATL_PHY_ID_MAX; in aq_nic_init()
430 err = aq_phy_init(self->aq_hw); in aq_nic_init()
437 if (self->aq_nic_cfg.aq_hw_caps->quirks & AQ_NIC_QUIRK_BAD_PTP) in aq_nic_init()
438 if (self->aq_hw->phy_id != HW_ATL_PHY_ID_MAX) in aq_nic_init()
439 aq_phy_disable_ptp(self->aq_hw); in aq_nic_init()
442 for (i = 0U; i < self->aq_vecs; i++) { in aq_nic_init()
443 aq_vec = self->aq_vec[i]; in aq_nic_init()
444 err = aq_vec_ring_alloc(aq_vec, self, i, in aq_nic_init()
445 aq_nic_get_cfg(self)); in aq_nic_init()
449 aq_vec_init(aq_vec, self->aq_hw_ops, self->aq_hw); in aq_nic_init()
452 if (aq_nic_get_cfg(self)->is_ptp) { in aq_nic_init()
453 err = aq_ptp_init(self, self->irqvecs - 1); in aq_nic_init()
457 err = aq_ptp_ring_alloc(self); in aq_nic_init()
461 err = aq_ptp_ring_init(self); in aq_nic_init()
466 netif_carrier_off(self->ndev); in aq_nic_init()
472 int aq_nic_start(struct aq_nic_s *self) in aq_nic_start() argument
479 cfg = aq_nic_get_cfg(self); in aq_nic_start()
481 err = self->aq_hw_ops->hw_multicast_list_set(self->aq_hw, in aq_nic_start()
482 self->mc_list.ar, in aq_nic_start()
483 self->mc_list.count); in aq_nic_start()
487 err = self->aq_hw_ops->hw_packet_filter_set(self->aq_hw, in aq_nic_start()
488 self->packet_filter); in aq_nic_start()
492 for (i = 0U; self->aq_vecs > i; ++i) { in aq_nic_start()
493 aq_vec = self->aq_vec[i]; in aq_nic_start()
499 err = aq_ptp_ring_start(self); in aq_nic_start()
503 aq_nic_set_loopback(self); in aq_nic_start()
505 err = self->aq_hw_ops->hw_start(self->aq_hw); in aq_nic_start()
509 err = aq_nic_update_interrupt_moderation_settings(self); in aq_nic_start()
513 INIT_WORK(&self->service_task, aq_nic_service_task); in aq_nic_start()
515 timer_setup(&self->service_timer, aq_nic_service_timer_cb, 0); in aq_nic_start()
516 aq_nic_service_timer_cb(&self->service_timer); in aq_nic_start()
519 timer_setup(&self->polling_timer, aq_nic_polling_timer_cb, 0); in aq_nic_start()
520 mod_timer(&self->polling_timer, jiffies + in aq_nic_start()
523 for (i = 0U; self->aq_vecs > i; ++i) { in aq_nic_start()
524 aq_vec = self->aq_vec[i]; in aq_nic_start()
525 err = aq_pci_func_alloc_irq(self, i, self->ndev->name, in aq_nic_start()
532 err = aq_ptp_irq_alloc(self); in aq_nic_start()
537 int irqvec = pci_irq_vector(self->pdev, in aq_nic_start()
542 self->ndev->name, self); in aq_nic_start()
545 self->msix_entry_mask |= (1 << cfg->link_irq_vec); in aq_nic_start()
548 err = self->aq_hw_ops->hw_irq_enable(self->aq_hw, in aq_nic_start()
554 err = netif_set_real_num_tx_queues(self->ndev, in aq_nic_start()
555 self->aq_vecs * cfg->tcs); in aq_nic_start()
559 err = netif_set_real_num_rx_queues(self->ndev, in aq_nic_start()
560 self->aq_vecs * cfg->tcs); in aq_nic_start()
565 u16 offset = self->aq_vecs * i; in aq_nic_start()
567 netdev_set_tc_queue(self->ndev, i, self->aq_vecs, offset); in aq_nic_start()
569 netif_tx_start_all_queues(self->ndev); in aq_nic_start()
575 static unsigned int aq_nic_map_xdp(struct aq_nic_s *self, in aq_nic_map_xdp() argument
579 struct device *dev = aq_nic_get_dev(self); in aq_nic_map_xdp()
672 unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, in aq_nic_map_skb() argument
676 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self); in aq_nic_map_skb()
677 struct device *dev = aq_nic_get_dev(self); in aq_nic_map_skb()
867 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb) in aq_nic_xmit() argument
869 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self); in aq_nic_xmit()
878 ring = self->aq_ring_tx[AQ_NIC_CFG_TCVEC2RING(cfg, tc, vec)]; in aq_nic_xmit()
893 if (__netif_subqueue_stopped(self->ndev, in aq_nic_xmit()
894 AQ_NIC_RING2QMAP(self, ring->idx))) { in aq_nic_xmit()
899 frags = aq_nic_map_skb(self, skb, ring); in aq_nic_xmit()
902 err = self->aq_hw_ops->hw_ring_tx_xmit(self->aq_hw, in aq_nic_xmit()
912 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self) in aq_nic_update_interrupt_moderation_settings() argument
914 return self->aq_hw_ops->hw_interrupt_moderation_set(self->aq_hw); in aq_nic_update_interrupt_moderation_settings()
917 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags) in aq_nic_set_packet_filter() argument
921 err = self->aq_hw_ops->hw_packet_filter_set(self->aq_hw, flags); in aq_nic_set_packet_filter()
925 self->packet_filter = flags; in aq_nic_set_packet_filter()
931 int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev) in aq_nic_set_multicast_list() argument
933 const struct aq_hw_ops *hw_ops = self->aq_hw_ops; in aq_nic_set_multicast_list()
934 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_multicast_list()
940 self->mc_list.count = 0; in aq_nic_set_multicast_list()
945 ether_addr_copy(self->mc_list.ar[i++], ha->addr); in aq_nic_set_multicast_list()
955 ether_addr_copy(self->mc_list.ar[i++], in aq_nic_set_multicast_list()
962 self->mc_list.count = i; in aq_nic_set_multicast_list()
963 err = hw_ops->hw_multicast_list_set(self->aq_hw, in aq_nic_set_multicast_list()
964 self->mc_list.ar, in aq_nic_set_multicast_list()
965 self->mc_list.count); in aq_nic_set_multicast_list()
970 return aq_nic_set_packet_filter(self, packet_filter); in aq_nic_set_multicast_list()
973 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu) in aq_nic_set_mtu() argument
975 self->aq_nic_cfg.mtu = new_mtu; in aq_nic_set_mtu()
980 int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev) in aq_nic_set_mac() argument
982 return self->aq_hw_ops->hw_set_mac_address(self->aq_hw, ndev->dev_addr); in aq_nic_set_mac()
985 unsigned int aq_nic_get_link_speed(struct aq_nic_s *self) in aq_nic_get_link_speed() argument
987 return self->link_status.mbps; in aq_nic_get_link_speed()
990 int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p) in aq_nic_get_regs() argument
995 if (unlikely(!self->aq_hw_ops->hw_get_regs)) in aq_nic_get_regs()
1000 err = self->aq_hw_ops->hw_get_regs(self->aq_hw, in aq_nic_get_regs()
1001 self->aq_nic_cfg.aq_hw_caps, in aq_nic_get_regs()
1010 int aq_nic_get_regs_count(struct aq_nic_s *self) in aq_nic_get_regs_count() argument
1012 if (unlikely(!self->aq_hw_ops->hw_get_regs)) in aq_nic_get_regs_count()
1015 return self->aq_nic_cfg.aq_hw_caps->mac_regs_count; in aq_nic_get_regs_count()
1018 u64 *aq_nic_get_stats(struct aq_nic_s *self, u64 *data) in aq_nic_get_stats() argument
1025 if (self->aq_fw_ops->update_stats) { in aq_nic_get_stats()
1026 mutex_lock(&self->fwreq_mutex); in aq_nic_get_stats()
1027 self->aq_fw_ops->update_stats(self->aq_hw); in aq_nic_get_stats()
1028 mutex_unlock(&self->fwreq_mutex); in aq_nic_get_stats()
1030 stats = self->aq_hw_ops->hw_get_hw_stats(self->aq_hw); in aq_nic_get_stats()
1068 for (tc = 0U; tc < self->aq_nic_cfg.tcs; tc++) { in aq_nic_get_stats()
1069 for (i = 0U; self->aq_vecs > i; ++i) { in aq_nic_get_stats()
1070 if (!self->aq_vec[i]) in aq_nic_get_stats()
1073 count = aq_vec_get_sw_stats(self->aq_vec[i], tc, data); in aq_nic_get_stats()
1083 static void aq_nic_update_ndev_stats(struct aq_nic_s *self) in aq_nic_update_ndev_stats() argument
1085 struct aq_stats_s *stats = self->aq_hw_ops->hw_get_hw_stats(self->aq_hw); in aq_nic_update_ndev_stats()
1086 struct net_device *ndev = self->ndev; in aq_nic_update_ndev_stats()
1098 void aq_nic_get_link_ksettings(struct aq_nic_s *self, in aq_nic_get_link_ksettings() argument
1103 if (self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_FIBRE) in aq_nic_get_link_ksettings()
1109 if (self->link_status.mbps) in aq_nic_get_link_ksettings()
1110 cmd->base.duplex = self->link_status.full_duplex ? in aq_nic_get_link_ksettings()
1112 cmd->base.autoneg = self->aq_nic_cfg.is_autoneg; in aq_nic_get_link_ksettings()
1116 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_10G) in aq_nic_get_link_ksettings()
1120 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_5G) in aq_nic_get_link_ksettings()
1124 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_2G5) in aq_nic_get_link_ksettings()
1128 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_1G) in aq_nic_get_link_ksettings()
1132 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_1G_HALF) in aq_nic_get_link_ksettings()
1136 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_100M) in aq_nic_get_link_ksettings()
1140 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_100M_HALF) in aq_nic_get_link_ksettings()
1144 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_10M) in aq_nic_get_link_ksettings()
1148 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_10M_HALF) in aq_nic_get_link_ksettings()
1152 if (self->aq_nic_cfg.aq_hw_caps->flow_control) { in aq_nic_get_link_ksettings()
1161 if (self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_FIBRE) in aq_nic_get_link_ksettings()
1168 if (self->aq_nic_cfg.is_autoneg) in aq_nic_get_link_ksettings()
1171 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_10G) in aq_nic_get_link_ksettings()
1175 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_5G) in aq_nic_get_link_ksettings()
1179 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_2G5) in aq_nic_get_link_ksettings()
1183 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_1G) in aq_nic_get_link_ksettings()
1187 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_1G_HALF) in aq_nic_get_link_ksettings()
1191 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_100M) in aq_nic_get_link_ksettings()
1195 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_100M_HALF) in aq_nic_get_link_ksettings()
1199 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_10M) in aq_nic_get_link_ksettings()
1203 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_10M_HALF) in aq_nic_get_link_ksettings()
1207 if (self->aq_nic_cfg.fc.cur & AQ_NIC_FC_RX) in aq_nic_get_link_ksettings()
1212 if (!!(self->aq_nic_cfg.fc.cur & AQ_NIC_FC_TX) ^ in aq_nic_get_link_ksettings()
1213 !!(self->aq_nic_cfg.fc.cur & AQ_NIC_FC_RX)) in aq_nic_get_link_ksettings()
1217 if (self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_FIBRE) in aq_nic_get_link_ksettings()
1223 lp_link_speed_msk = self->aq_hw->aq_link_status.lp_link_speed_msk; in aq_nic_get_link_ksettings()
1261 if (self->aq_hw->aq_link_status.lp_flow_control & AQ_NIC_FC_RX) in aq_nic_get_link_ksettings()
1264 if (!!(self->aq_hw->aq_link_status.lp_flow_control & AQ_NIC_FC_TX) ^ in aq_nic_get_link_ksettings()
1265 !!(self->aq_hw->aq_link_status.lp_flow_control & AQ_NIC_FC_RX)) in aq_nic_get_link_ksettings()
1270 int aq_nic_set_link_ksettings(struct aq_nic_s *self, in aq_nic_set_link_ksettings() argument
1284 rate = self->aq_nic_cfg.aq_hw_caps->link_speed_msk; in aq_nic_set_link_ksettings()
1285 self->aq_nic_cfg.is_autoneg = true; in aq_nic_set_link_ksettings()
1317 if (!(self->aq_nic_cfg.aq_hw_caps->link_speed_msk & rate)) { in aq_nic_set_link_ksettings()
1322 self->aq_nic_cfg.is_autoneg = false; in aq_nic_set_link_ksettings()
1325 mutex_lock(&self->fwreq_mutex); in aq_nic_set_link_ksettings()
1326 err = self->aq_fw_ops->set_link_speed(self->aq_hw, rate); in aq_nic_set_link_ksettings()
1327 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_link_ksettings()
1331 self->aq_nic_cfg.link_speed_msk = rate; in aq_nic_set_link_ksettings()
1337 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self) in aq_nic_get_cfg() argument
1339 return &self->aq_nic_cfg; in aq_nic_get_cfg()
1342 u32 aq_nic_get_fw_version(struct aq_nic_s *self) in aq_nic_get_fw_version() argument
1344 return self->aq_hw_ops->hw_get_fw_version(self->aq_hw); in aq_nic_get_fw_version()
1347 int aq_nic_set_loopback(struct aq_nic_s *self) in aq_nic_set_loopback() argument
1349 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_loopback()
1351 if (!self->aq_hw_ops->hw_set_loopback || in aq_nic_set_loopback()
1352 !self->aq_fw_ops->set_phyloopback) in aq_nic_set_loopback()
1355 mutex_lock(&self->fwreq_mutex); in aq_nic_set_loopback()
1356 self->aq_hw_ops->hw_set_loopback(self->aq_hw, in aq_nic_set_loopback()
1361 self->aq_hw_ops->hw_set_loopback(self->aq_hw, in aq_nic_set_loopback()
1366 self->aq_hw_ops->hw_set_loopback(self->aq_hw, in aq_nic_set_loopback()
1371 self->aq_fw_ops->set_phyloopback(self->aq_hw, in aq_nic_set_loopback()
1376 self->aq_fw_ops->set_phyloopback(self->aq_hw, in aq_nic_set_loopback()
1380 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_loopback()
1385 int aq_nic_stop(struct aq_nic_s *self) in aq_nic_stop() argument
1389 netif_tx_disable(self->ndev); in aq_nic_stop()
1390 netif_carrier_off(self->ndev); in aq_nic_stop()
1392 del_timer_sync(&self->service_timer); in aq_nic_stop()
1393 cancel_work_sync(&self->service_task); in aq_nic_stop()
1395 self->aq_hw_ops->hw_irq_disable(self->aq_hw, AQ_CFG_IRQ_MASK); in aq_nic_stop()
1397 if (self->aq_nic_cfg.is_polling) in aq_nic_stop()
1398 del_timer_sync(&self->polling_timer); in aq_nic_stop()
1400 aq_pci_func_free_irqs(self); in aq_nic_stop()
1402 aq_ptp_irq_free(self); in aq_nic_stop()
1404 for (i = 0U; self->aq_vecs > i; ++i) in aq_nic_stop()
1405 aq_vec_stop(self->aq_vec[i]); in aq_nic_stop()
1407 aq_ptp_ring_stop(self); in aq_nic_stop()
1409 return self->aq_hw_ops->hw_stop(self->aq_hw); in aq_nic_stop()
1412 void aq_nic_set_power(struct aq_nic_s *self) in aq_nic_set_power() argument
1414 if (self->power_state != AQ_HW_POWER_STATE_D0 || in aq_nic_set_power()
1415 self->aq_hw->aq_nic_cfg->wol) in aq_nic_set_power()
1416 if (likely(self->aq_fw_ops->set_power)) { in aq_nic_set_power()
1417 mutex_lock(&self->fwreq_mutex); in aq_nic_set_power()
1418 self->aq_fw_ops->set_power(self->aq_hw, in aq_nic_set_power()
1419 self->power_state, in aq_nic_set_power()
1420 self->ndev->dev_addr); in aq_nic_set_power()
1421 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_power()
1425 void aq_nic_deinit(struct aq_nic_s *self, bool link_down) in aq_nic_deinit() argument
1430 if (!self) in aq_nic_deinit()
1433 for (i = 0U; i < self->aq_vecs; i++) { in aq_nic_deinit()
1434 aq_vec = self->aq_vec[i]; in aq_nic_deinit()
1439 aq_ptp_unregister(self); in aq_nic_deinit()
1440 aq_ptp_ring_deinit(self); in aq_nic_deinit()
1441 aq_ptp_ring_free(self); in aq_nic_deinit()
1442 aq_ptp_free(self); in aq_nic_deinit()
1444 if (likely(self->aq_fw_ops->deinit) && link_down) { in aq_nic_deinit()
1445 mutex_lock(&self->fwreq_mutex); in aq_nic_deinit()
1446 self->aq_fw_ops->deinit(self->aq_hw); in aq_nic_deinit()
1447 mutex_unlock(&self->fwreq_mutex); in aq_nic_deinit()
1453 void aq_nic_free_vectors(struct aq_nic_s *self) in aq_nic_free_vectors() argument
1457 if (!self) in aq_nic_free_vectors()
1460 for (i = ARRAY_SIZE(self->aq_vec); i--;) { in aq_nic_free_vectors()
1461 if (self->aq_vec[i]) { in aq_nic_free_vectors()
1462 aq_vec_free(self->aq_vec[i]); in aq_nic_free_vectors()
1463 self->aq_vec[i] = NULL; in aq_nic_free_vectors()
1470 int aq_nic_realloc_vectors(struct aq_nic_s *self) in aq_nic_realloc_vectors() argument
1472 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self); in aq_nic_realloc_vectors()
1474 aq_nic_free_vectors(self); in aq_nic_realloc_vectors()
1476 for (self->aq_vecs = 0; self->aq_vecs < cfg->vecs; self->aq_vecs++) { in aq_nic_realloc_vectors()
1477 self->aq_vec[self->aq_vecs] = aq_vec_alloc(self, self->aq_vecs, in aq_nic_realloc_vectors()
1479 if (unlikely(!self->aq_vec[self->aq_vecs])) in aq_nic_realloc_vectors()
1486 void aq_nic_shutdown(struct aq_nic_s *self) in aq_nic_shutdown() argument
1490 if (!self->ndev) in aq_nic_shutdown()
1495 netif_device_detach(self->ndev); in aq_nic_shutdown()
1497 if (netif_running(self->ndev)) { in aq_nic_shutdown()
1498 err = aq_nic_stop(self); in aq_nic_shutdown()
1502 aq_nic_deinit(self, !self->aq_hw->aq_nic_cfg->wol); in aq_nic_shutdown()
1503 aq_nic_set_power(self); in aq_nic_shutdown()
1509 u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type) in aq_nic_reserve_filter() argument
1518 self->aq_hw_rx_fltrs.fet_reserved_count; in aq_nic_reserve_filter()
1519 self->aq_hw_rx_fltrs.fet_reserved_count++; in aq_nic_reserve_filter()
1523 n_bit = fltr_cnt - self->aq_hw_rx_fltrs.fl3l4.reserved_count; in aq_nic_reserve_filter()
1525 self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |= BIT(n_bit); in aq_nic_reserve_filter()
1526 self->aq_hw_rx_fltrs.fl3l4.reserved_count++; in aq_nic_reserve_filter()
1536 void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type, in aq_nic_release_filter() argument
1541 self->aq_hw_rx_fltrs.fet_reserved_count--; in aq_nic_release_filter()
1544 self->aq_hw_rx_fltrs.fl3l4.reserved_count--; in aq_nic_release_filter()
1545 self->aq_hw_rx_fltrs.fl3l4.active_ipv4 &= ~BIT(location); in aq_nic_release_filter()
1552 int aq_nic_set_downshift(struct aq_nic_s *self, int val) in aq_nic_set_downshift() argument
1555 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_downshift()
1557 if (!self->aq_fw_ops->set_downshift) in aq_nic_set_downshift()
1561 netdev_err(self->ndev, "downshift counter should be <= 15\n"); in aq_nic_set_downshift()
1566 mutex_lock(&self->fwreq_mutex); in aq_nic_set_downshift()
1567 err = self->aq_fw_ops->set_downshift(self->aq_hw, cfg->downshift_counter); in aq_nic_set_downshift()
1568 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_downshift()
1573 int aq_nic_set_media_detect(struct aq_nic_s *self, int val) in aq_nic_set_media_detect() argument
1575 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_media_detect()
1578 if (!self->aq_fw_ops->set_media_detect) in aq_nic_set_media_detect()
1582 netdev_err(self->ndev, "EDPD on this device could have only fixed value of %d\n", in aq_nic_set_media_detect()
1587 mutex_lock(&self->fwreq_mutex); in aq_nic_set_media_detect()
1588 err = self->aq_fw_ops->set_media_detect(self->aq_hw, !!val); in aq_nic_set_media_detect()
1589 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_media_detect()
1598 int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 tcs, u8 *prio_tc_map) in aq_nic_setup_tc_mqprio() argument
1600 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_setup_tc_mqprio()
1612 ndev_running = netif_running(self->ndev); in aq_nic_setup_tc_mqprio()
1614 dev_close(self->ndev); in aq_nic_setup_tc_mqprio()
1628 netdev_warn(self->ndev, "%s\n", in aq_nic_setup_tc_mqprio()
1631 netdev_set_num_tc(self->ndev, cfg->tcs); in aq_nic_setup_tc_mqprio()
1634 aq_nic_cfg_update_num_vecs(self); in aq_nic_setup_tc_mqprio()
1636 err = aq_nic_realloc_vectors(self); in aq_nic_setup_tc_mqprio()
1642 err = dev_open(self->ndev, NULL); in aq_nic_setup_tc_mqprio()
1648 int aq_nic_setup_tc_max_rate(struct aq_nic_s *self, const unsigned int tc, in aq_nic_setup_tc_max_rate() argument
1651 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_setup_tc_max_rate()
1657 netdev_warn(self->ndev, in aq_nic_setup_tc_max_rate()
1668 int aq_nic_setup_tc_min_rate(struct aq_nic_s *self, const unsigned int tc, in aq_nic_setup_tc_min_rate() argument
1671 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_setup_tc_min_rate()
1682 netdev_warn(self->ndev, in aq_nic_setup_tc_min_rate()