Lines Matching refs: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
271 for (i = 0U, aq_vec = self->aq_vec[0]; in aq_nic_polling_timer_cb()
272 self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) in aq_nic_polling_timer_cb()
275 mod_timer(&self->polling_timer, jiffies + in aq_nic_polling_timer_cb()
279 static int aq_nic_hw_prepare(struct aq_nic_s *self) in aq_nic_hw_prepare() argument
283 err = self->aq_hw_ops->hw_soft_reset(self->aq_hw); in aq_nic_hw_prepare()
287 err = self->aq_hw_ops->hw_prepare(self->aq_hw, &self->aq_fw_ops); in aq_nic_hw_prepare()
301 int aq_nic_ndev_register(struct aq_nic_s *self) in aq_nic_ndev_register() argument
306 if (!self->ndev) { in aq_nic_ndev_register()
311 err = aq_nic_hw_prepare(self); in aq_nic_ndev_register()
316 aq_macsec_init(self); in aq_nic_ndev_register()
319 if (platform_get_ethdev_address(&self->pdev->dev, self->ndev) != 0) { in aq_nic_ndev_register()
321 mutex_lock(&self->fwreq_mutex); in aq_nic_ndev_register()
322 err = self->aq_fw_ops->get_mac_permanent(self->aq_hw, addr); in aq_nic_ndev_register()
323 mutex_unlock(&self->fwreq_mutex); in aq_nic_ndev_register()
330 eth_hw_addr_set(self->ndev, addr); in aq_nic_ndev_register()
332 netdev_warn(self->ndev, "MAC is invalid, will use random."); in aq_nic_ndev_register()
333 eth_hw_addr_random(self->ndev); in aq_nic_ndev_register()
341 eth_hw_addr_set(self->ndev, mac_addr_permanent); in aq_nic_ndev_register()
345 for (self->aq_vecs = 0; self->aq_vecs < aq_nic_get_cfg(self)->vecs; in aq_nic_ndev_register()
346 self->aq_vecs++) { in aq_nic_ndev_register()
347 self->aq_vec[self->aq_vecs] = in aq_nic_ndev_register()
348 aq_vec_alloc(self, self->aq_vecs, aq_nic_get_cfg(self)); in aq_nic_ndev_register()
349 if (!self->aq_vec[self->aq_vecs]) { in aq_nic_ndev_register()
355 netif_carrier_off(self->ndev); in aq_nic_ndev_register()
357 netif_tx_disable(self->ndev); in aq_nic_ndev_register()
359 err = register_netdev(self->ndev); in aq_nic_ndev_register()
366 aq_macsec_free(self); in aq_nic_ndev_register()
371 void aq_nic_ndev_init(struct aq_nic_s *self) in aq_nic_ndev_init() argument
373 const struct aq_hw_caps_s *aq_hw_caps = self->aq_nic_cfg.aq_hw_caps; in aq_nic_ndev_init()
374 struct aq_nic_cfg_s *aq_nic_cfg = &self->aq_nic_cfg; in aq_nic_ndev_init()
376 self->ndev->hw_features |= aq_hw_caps->hw_features; in aq_nic_ndev_init()
377 self->ndev->features = aq_hw_caps->hw_features; in aq_nic_ndev_init()
378 self->ndev->vlan_features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM | in aq_nic_ndev_init()
381 self->ndev->gso_partial_features = NETIF_F_GSO_UDP_L4; in aq_nic_ndev_init()
382 self->ndev->priv_flags = aq_hw_caps->hw_priv_flags; in aq_nic_ndev_init()
383 self->ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; in aq_nic_ndev_init()
385 self->msg_enable = NETIF_MSG_DRV | NETIF_MSG_LINK; in aq_nic_ndev_init()
386 self->ndev->mtu = aq_nic_cfg->mtu - ETH_HLEN; in aq_nic_ndev_init()
387 self->ndev->max_mtu = aq_hw_caps->mtu - ETH_FCS_LEN - ETH_HLEN; in aq_nic_ndev_init()
391 void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx, in aq_nic_set_tx_ring() argument
394 self->aq_ring_tx[idx] = ring; in aq_nic_set_tx_ring()
397 struct net_device *aq_nic_get_ndev(struct aq_nic_s *self) in aq_nic_get_ndev() argument
399 return self->ndev; in aq_nic_get_ndev()
402 int aq_nic_init(struct aq_nic_s *self) in aq_nic_init() argument
408 self->power_state = AQ_HW_POWER_STATE_D0; in aq_nic_init()
409 mutex_lock(&self->fwreq_mutex); in aq_nic_init()
410 err = self->aq_hw_ops->hw_reset(self->aq_hw); in aq_nic_init()
411 mutex_unlock(&self->fwreq_mutex); in aq_nic_init()
415 aq_nic_set_downshift(self, self->aq_nic_cfg.downshift_counter); in aq_nic_init()
416 aq_nic_set_media_detect(self, self->aq_nic_cfg.is_media_detect ? in aq_nic_init()
419 err = self->aq_hw_ops->hw_init(self->aq_hw, in aq_nic_init()
420 aq_nic_get_ndev(self)->dev_addr); in aq_nic_init()
424 if (ATL_HW_IS_CHIP_FEATURE(self->aq_hw, ATLANTIC) && in aq_nic_init()
425 self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_TP) { in aq_nic_init()
426 self->aq_hw->phy_id = HW_ATL_PHY_ID_MAX; in aq_nic_init()
427 err = aq_phy_init(self->aq_hw); in aq_nic_init()
434 if (self->aq_nic_cfg.aq_hw_caps->quirks & AQ_NIC_QUIRK_BAD_PTP) in aq_nic_init()
435 if (self->aq_hw->phy_id != HW_ATL_PHY_ID_MAX) in aq_nic_init()
436 aq_phy_disable_ptp(self->aq_hw); in aq_nic_init()
439 for (i = 0U; i < self->aq_vecs; i++) { in aq_nic_init()
440 aq_vec = self->aq_vec[i]; in aq_nic_init()
441 err = aq_vec_ring_alloc(aq_vec, self, i, in aq_nic_init()
442 aq_nic_get_cfg(self)); in aq_nic_init()
446 aq_vec_init(aq_vec, self->aq_hw_ops, self->aq_hw); in aq_nic_init()
449 if (aq_nic_get_cfg(self)->is_ptp) { in aq_nic_init()
450 err = aq_ptp_init(self, self->irqvecs - 1); in aq_nic_init()
454 err = aq_ptp_ring_alloc(self); in aq_nic_init()
458 err = aq_ptp_ring_init(self); in aq_nic_init()
463 netif_carrier_off(self->ndev); in aq_nic_init()
469 int aq_nic_start(struct aq_nic_s *self) in aq_nic_start() argument
476 cfg = aq_nic_get_cfg(self); in aq_nic_start()
478 err = self->aq_hw_ops->hw_multicast_list_set(self->aq_hw, in aq_nic_start()
479 self->mc_list.ar, in aq_nic_start()
480 self->mc_list.count); in aq_nic_start()
484 err = self->aq_hw_ops->hw_packet_filter_set(self->aq_hw, in aq_nic_start()
485 self->packet_filter); in aq_nic_start()
489 for (i = 0U, aq_vec = self->aq_vec[0]; in aq_nic_start()
490 self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) { in aq_nic_start()
496 err = aq_ptp_ring_start(self); in aq_nic_start()
500 aq_nic_set_loopback(self); in aq_nic_start()
502 err = self->aq_hw_ops->hw_start(self->aq_hw); in aq_nic_start()
506 err = aq_nic_update_interrupt_moderation_settings(self); in aq_nic_start()
510 INIT_WORK(&self->service_task, aq_nic_service_task); in aq_nic_start()
512 timer_setup(&self->service_timer, aq_nic_service_timer_cb, 0); in aq_nic_start()
513 aq_nic_service_timer_cb(&self->service_timer); in aq_nic_start()
516 timer_setup(&self->polling_timer, aq_nic_polling_timer_cb, 0); in aq_nic_start()
517 mod_timer(&self->polling_timer, jiffies + in aq_nic_start()
520 for (i = 0U, aq_vec = self->aq_vec[0]; in aq_nic_start()
521 self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) { in aq_nic_start()
522 err = aq_pci_func_alloc_irq(self, i, self->ndev->name, in aq_nic_start()
529 err = aq_ptp_irq_alloc(self); in aq_nic_start()
534 int irqvec = pci_irq_vector(self->pdev, in aq_nic_start()
539 self->ndev->name, self); in aq_nic_start()
542 self->msix_entry_mask |= (1 << cfg->link_irq_vec); in aq_nic_start()
545 err = self->aq_hw_ops->hw_irq_enable(self->aq_hw, in aq_nic_start()
551 err = netif_set_real_num_tx_queues(self->ndev, in aq_nic_start()
552 self->aq_vecs * cfg->tcs); in aq_nic_start()
556 err = netif_set_real_num_rx_queues(self->ndev, in aq_nic_start()
557 self->aq_vecs * cfg->tcs); in aq_nic_start()
562 u16 offset = self->aq_vecs * i; in aq_nic_start()
564 netdev_set_tc_queue(self->ndev, i, self->aq_vecs, offset); in aq_nic_start()
566 netif_tx_start_all_queues(self->ndev); in aq_nic_start()
572 unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb, in aq_nic_map_skb() argument
576 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self); in aq_nic_map_skb()
577 struct device *dev = aq_nic_get_dev(self); in aq_nic_map_skb()
728 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb) in aq_nic_xmit() argument
730 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self); in aq_nic_xmit()
739 ring = self->aq_ring_tx[AQ_NIC_CFG_TCVEC2RING(cfg, tc, vec)]; in aq_nic_xmit()
754 if (__netif_subqueue_stopped(self->ndev, in aq_nic_xmit()
755 AQ_NIC_RING2QMAP(self, ring->idx))) { in aq_nic_xmit()
760 frags = aq_nic_map_skb(self, skb, ring); in aq_nic_xmit()
763 err = self->aq_hw_ops->hw_ring_tx_xmit(self->aq_hw, in aq_nic_xmit()
773 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self) in aq_nic_update_interrupt_moderation_settings() argument
775 return self->aq_hw_ops->hw_interrupt_moderation_set(self->aq_hw); in aq_nic_update_interrupt_moderation_settings()
778 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags) in aq_nic_set_packet_filter() argument
782 err = self->aq_hw_ops->hw_packet_filter_set(self->aq_hw, flags); in aq_nic_set_packet_filter()
786 self->packet_filter = flags; in aq_nic_set_packet_filter()
792 int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev) in aq_nic_set_multicast_list() argument
794 const struct aq_hw_ops *hw_ops = self->aq_hw_ops; in aq_nic_set_multicast_list()
795 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_multicast_list()
801 self->mc_list.count = 0; in aq_nic_set_multicast_list()
806 ether_addr_copy(self->mc_list.ar[i++], ha->addr); in aq_nic_set_multicast_list()
816 ether_addr_copy(self->mc_list.ar[i++], in aq_nic_set_multicast_list()
823 self->mc_list.count = i; in aq_nic_set_multicast_list()
824 err = hw_ops->hw_multicast_list_set(self->aq_hw, in aq_nic_set_multicast_list()
825 self->mc_list.ar, in aq_nic_set_multicast_list()
826 self->mc_list.count); in aq_nic_set_multicast_list()
831 return aq_nic_set_packet_filter(self, packet_filter); in aq_nic_set_multicast_list()
834 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu) in aq_nic_set_mtu() argument
836 self->aq_nic_cfg.mtu = new_mtu; in aq_nic_set_mtu()
841 int aq_nic_set_mac(struct aq_nic_s *self, struct net_device *ndev) in aq_nic_set_mac() argument
843 return self->aq_hw_ops->hw_set_mac_address(self->aq_hw, ndev->dev_addr); in aq_nic_set_mac()
846 unsigned int aq_nic_get_link_speed(struct aq_nic_s *self) in aq_nic_get_link_speed() argument
848 return self->link_status.mbps; in aq_nic_get_link_speed()
851 int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p) in aq_nic_get_regs() argument
856 if (unlikely(!self->aq_hw_ops->hw_get_regs)) in aq_nic_get_regs()
861 err = self->aq_hw_ops->hw_get_regs(self->aq_hw, in aq_nic_get_regs()
862 self->aq_nic_cfg.aq_hw_caps, in aq_nic_get_regs()
871 int aq_nic_get_regs_count(struct aq_nic_s *self) in aq_nic_get_regs_count() argument
873 if (unlikely(!self->aq_hw_ops->hw_get_regs)) in aq_nic_get_regs_count()
876 return self->aq_nic_cfg.aq_hw_caps->mac_regs_count; in aq_nic_get_regs_count()
879 u64 *aq_nic_get_stats(struct aq_nic_s *self, u64 *data) in aq_nic_get_stats() argument
887 if (self->aq_fw_ops->update_stats) { in aq_nic_get_stats()
888 mutex_lock(&self->fwreq_mutex); in aq_nic_get_stats()
889 self->aq_fw_ops->update_stats(self->aq_hw); in aq_nic_get_stats()
890 mutex_unlock(&self->fwreq_mutex); in aq_nic_get_stats()
892 stats = self->aq_hw_ops->hw_get_hw_stats(self->aq_hw); in aq_nic_get_stats()
930 for (tc = 0U; tc < self->aq_nic_cfg.tcs; tc++) { in aq_nic_get_stats()
931 for (i = 0U, aq_vec = self->aq_vec[0]; in aq_nic_get_stats()
932 aq_vec && self->aq_vecs > i; in aq_nic_get_stats()
933 ++i, aq_vec = self->aq_vec[i]) { in aq_nic_get_stats()
945 static void aq_nic_update_ndev_stats(struct aq_nic_s *self) in aq_nic_update_ndev_stats() argument
947 struct aq_stats_s *stats = self->aq_hw_ops->hw_get_hw_stats(self->aq_hw); in aq_nic_update_ndev_stats()
948 struct net_device *ndev = self->ndev; in aq_nic_update_ndev_stats()
960 void aq_nic_get_link_ksettings(struct aq_nic_s *self, in aq_nic_get_link_ksettings() argument
965 if (self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_FIBRE) in aq_nic_get_link_ksettings()
971 if (self->link_status.mbps) in aq_nic_get_link_ksettings()
972 cmd->base.duplex = self->link_status.full_duplex ? in aq_nic_get_link_ksettings()
974 cmd->base.autoneg = self->aq_nic_cfg.is_autoneg; in aq_nic_get_link_ksettings()
978 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_10G) in aq_nic_get_link_ksettings()
982 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_5G) in aq_nic_get_link_ksettings()
986 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_2G5) in aq_nic_get_link_ksettings()
990 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_1G) in aq_nic_get_link_ksettings()
994 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_1G_HALF) in aq_nic_get_link_ksettings()
998 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_100M) in aq_nic_get_link_ksettings()
1002 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_100M_HALF) in aq_nic_get_link_ksettings()
1006 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_10M) in aq_nic_get_link_ksettings()
1010 if (self->aq_nic_cfg.aq_hw_caps->link_speed_msk & AQ_NIC_RATE_10M_HALF) in aq_nic_get_link_ksettings()
1014 if (self->aq_nic_cfg.aq_hw_caps->flow_control) { in aq_nic_get_link_ksettings()
1023 if (self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_FIBRE) in aq_nic_get_link_ksettings()
1030 if (self->aq_nic_cfg.is_autoneg) in aq_nic_get_link_ksettings()
1033 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_10G) in aq_nic_get_link_ksettings()
1037 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_5G) in aq_nic_get_link_ksettings()
1041 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_2G5) in aq_nic_get_link_ksettings()
1045 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_1G) in aq_nic_get_link_ksettings()
1049 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_1G_HALF) in aq_nic_get_link_ksettings()
1053 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_100M) in aq_nic_get_link_ksettings()
1057 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_100M_HALF) in aq_nic_get_link_ksettings()
1061 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_10M) in aq_nic_get_link_ksettings()
1065 if (self->aq_nic_cfg.link_speed_msk & AQ_NIC_RATE_10M_HALF) in aq_nic_get_link_ksettings()
1069 if (self->aq_nic_cfg.fc.cur & AQ_NIC_FC_RX) in aq_nic_get_link_ksettings()
1074 if (!!(self->aq_nic_cfg.fc.cur & AQ_NIC_FC_TX) ^ in aq_nic_get_link_ksettings()
1075 !!(self->aq_nic_cfg.fc.cur & AQ_NIC_FC_RX)) in aq_nic_get_link_ksettings()
1079 if (self->aq_nic_cfg.aq_hw_caps->media_type == AQ_HW_MEDIA_TYPE_FIBRE) in aq_nic_get_link_ksettings()
1085 lp_link_speed_msk = self->aq_hw->aq_link_status.lp_link_speed_msk; in aq_nic_get_link_ksettings()
1123 if (self->aq_hw->aq_link_status.lp_flow_control & AQ_NIC_FC_RX) in aq_nic_get_link_ksettings()
1126 if (!!(self->aq_hw->aq_link_status.lp_flow_control & AQ_NIC_FC_TX) ^ in aq_nic_get_link_ksettings()
1127 !!(self->aq_hw->aq_link_status.lp_flow_control & AQ_NIC_FC_RX)) in aq_nic_get_link_ksettings()
1132 int aq_nic_set_link_ksettings(struct aq_nic_s *self, in aq_nic_set_link_ksettings() argument
1146 rate = self->aq_nic_cfg.aq_hw_caps->link_speed_msk; in aq_nic_set_link_ksettings()
1147 self->aq_nic_cfg.is_autoneg = true; in aq_nic_set_link_ksettings()
1179 if (!(self->aq_nic_cfg.aq_hw_caps->link_speed_msk & rate)) { in aq_nic_set_link_ksettings()
1184 self->aq_nic_cfg.is_autoneg = false; in aq_nic_set_link_ksettings()
1187 mutex_lock(&self->fwreq_mutex); in aq_nic_set_link_ksettings()
1188 err = self->aq_fw_ops->set_link_speed(self->aq_hw, rate); in aq_nic_set_link_ksettings()
1189 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_link_ksettings()
1193 self->aq_nic_cfg.link_speed_msk = rate; in aq_nic_set_link_ksettings()
1199 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self) in aq_nic_get_cfg() argument
1201 return &self->aq_nic_cfg; in aq_nic_get_cfg()
1204 u32 aq_nic_get_fw_version(struct aq_nic_s *self) in aq_nic_get_fw_version() argument
1206 return self->aq_hw_ops->hw_get_fw_version(self->aq_hw); in aq_nic_get_fw_version()
1209 int aq_nic_set_loopback(struct aq_nic_s *self) in aq_nic_set_loopback() argument
1211 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_loopback()
1213 if (!self->aq_hw_ops->hw_set_loopback || in aq_nic_set_loopback()
1214 !self->aq_fw_ops->set_phyloopback) in aq_nic_set_loopback()
1217 mutex_lock(&self->fwreq_mutex); in aq_nic_set_loopback()
1218 self->aq_hw_ops->hw_set_loopback(self->aq_hw, in aq_nic_set_loopback()
1223 self->aq_hw_ops->hw_set_loopback(self->aq_hw, in aq_nic_set_loopback()
1228 self->aq_hw_ops->hw_set_loopback(self->aq_hw, in aq_nic_set_loopback()
1233 self->aq_fw_ops->set_phyloopback(self->aq_hw, in aq_nic_set_loopback()
1238 self->aq_fw_ops->set_phyloopback(self->aq_hw, in aq_nic_set_loopback()
1242 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_loopback()
1247 int aq_nic_stop(struct aq_nic_s *self) in aq_nic_stop() argument
1252 netif_tx_disable(self->ndev); in aq_nic_stop()
1253 netif_carrier_off(self->ndev); in aq_nic_stop()
1255 del_timer_sync(&self->service_timer); in aq_nic_stop()
1256 cancel_work_sync(&self->service_task); in aq_nic_stop()
1258 self->aq_hw_ops->hw_irq_disable(self->aq_hw, AQ_CFG_IRQ_MASK); in aq_nic_stop()
1260 if (self->aq_nic_cfg.is_polling) in aq_nic_stop()
1261 del_timer_sync(&self->polling_timer); in aq_nic_stop()
1263 aq_pci_func_free_irqs(self); in aq_nic_stop()
1265 aq_ptp_irq_free(self); in aq_nic_stop()
1267 for (i = 0U, aq_vec = self->aq_vec[0]; in aq_nic_stop()
1268 self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) in aq_nic_stop()
1271 aq_ptp_ring_stop(self); in aq_nic_stop()
1273 return self->aq_hw_ops->hw_stop(self->aq_hw); in aq_nic_stop()
1276 void aq_nic_set_power(struct aq_nic_s *self) in aq_nic_set_power() argument
1278 if (self->power_state != AQ_HW_POWER_STATE_D0 || in aq_nic_set_power()
1279 self->aq_hw->aq_nic_cfg->wol) in aq_nic_set_power()
1280 if (likely(self->aq_fw_ops->set_power)) { in aq_nic_set_power()
1281 mutex_lock(&self->fwreq_mutex); in aq_nic_set_power()
1282 self->aq_fw_ops->set_power(self->aq_hw, in aq_nic_set_power()
1283 self->power_state, in aq_nic_set_power()
1284 self->ndev->dev_addr); in aq_nic_set_power()
1285 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_power()
1289 void aq_nic_deinit(struct aq_nic_s *self, bool link_down) in aq_nic_deinit() argument
1294 if (!self) in aq_nic_deinit()
1297 for (i = 0U; i < self->aq_vecs; i++) { in aq_nic_deinit()
1298 aq_vec = self->aq_vec[i]; in aq_nic_deinit()
1303 aq_ptp_unregister(self); in aq_nic_deinit()
1304 aq_ptp_ring_deinit(self); in aq_nic_deinit()
1305 aq_ptp_ring_free(self); in aq_nic_deinit()
1306 aq_ptp_free(self); in aq_nic_deinit()
1308 if (likely(self->aq_fw_ops->deinit) && link_down) { in aq_nic_deinit()
1309 mutex_lock(&self->fwreq_mutex); in aq_nic_deinit()
1310 self->aq_fw_ops->deinit(self->aq_hw); in aq_nic_deinit()
1311 mutex_unlock(&self->fwreq_mutex); in aq_nic_deinit()
1317 void aq_nic_free_vectors(struct aq_nic_s *self) in aq_nic_free_vectors() argument
1321 if (!self) in aq_nic_free_vectors()
1324 for (i = ARRAY_SIZE(self->aq_vec); i--;) { in aq_nic_free_vectors()
1325 if (self->aq_vec[i]) { in aq_nic_free_vectors()
1326 aq_vec_free(self->aq_vec[i]); in aq_nic_free_vectors()
1327 self->aq_vec[i] = NULL; in aq_nic_free_vectors()
1334 int aq_nic_realloc_vectors(struct aq_nic_s *self) in aq_nic_realloc_vectors() argument
1336 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self); in aq_nic_realloc_vectors()
1338 aq_nic_free_vectors(self); in aq_nic_realloc_vectors()
1340 for (self->aq_vecs = 0; self->aq_vecs < cfg->vecs; self->aq_vecs++) { in aq_nic_realloc_vectors()
1341 self->aq_vec[self->aq_vecs] = aq_vec_alloc(self, self->aq_vecs, in aq_nic_realloc_vectors()
1343 if (unlikely(!self->aq_vec[self->aq_vecs])) in aq_nic_realloc_vectors()
1350 void aq_nic_shutdown(struct aq_nic_s *self) in aq_nic_shutdown() argument
1354 if (!self->ndev) in aq_nic_shutdown()
1359 netif_device_detach(self->ndev); in aq_nic_shutdown()
1361 if (netif_running(self->ndev)) { in aq_nic_shutdown()
1362 err = aq_nic_stop(self); in aq_nic_shutdown()
1366 aq_nic_deinit(self, !self->aq_hw->aq_nic_cfg->wol); in aq_nic_shutdown()
1367 aq_nic_set_power(self); in aq_nic_shutdown()
1373 u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type) in aq_nic_reserve_filter() argument
1382 self->aq_hw_rx_fltrs.fet_reserved_count; in aq_nic_reserve_filter()
1383 self->aq_hw_rx_fltrs.fet_reserved_count++; in aq_nic_reserve_filter()
1387 n_bit = fltr_cnt - self->aq_hw_rx_fltrs.fl3l4.reserved_count; in aq_nic_reserve_filter()
1389 self->aq_hw_rx_fltrs.fl3l4.active_ipv4 |= BIT(n_bit); in aq_nic_reserve_filter()
1390 self->aq_hw_rx_fltrs.fl3l4.reserved_count++; in aq_nic_reserve_filter()
1400 void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type, in aq_nic_release_filter() argument
1405 self->aq_hw_rx_fltrs.fet_reserved_count--; in aq_nic_release_filter()
1408 self->aq_hw_rx_fltrs.fl3l4.reserved_count--; in aq_nic_release_filter()
1409 self->aq_hw_rx_fltrs.fl3l4.active_ipv4 &= ~BIT(location); in aq_nic_release_filter()
1416 int aq_nic_set_downshift(struct aq_nic_s *self, int val) in aq_nic_set_downshift() argument
1419 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_downshift()
1421 if (!self->aq_fw_ops->set_downshift) in aq_nic_set_downshift()
1425 netdev_err(self->ndev, "downshift counter should be <= 15\n"); in aq_nic_set_downshift()
1430 mutex_lock(&self->fwreq_mutex); in aq_nic_set_downshift()
1431 err = self->aq_fw_ops->set_downshift(self->aq_hw, cfg->downshift_counter); in aq_nic_set_downshift()
1432 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_downshift()
1437 int aq_nic_set_media_detect(struct aq_nic_s *self, int val) in aq_nic_set_media_detect() argument
1439 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_set_media_detect()
1442 if (!self->aq_fw_ops->set_media_detect) in aq_nic_set_media_detect()
1446 netdev_err(self->ndev, "EDPD on this device could have only fixed value of %d\n", in aq_nic_set_media_detect()
1451 mutex_lock(&self->fwreq_mutex); in aq_nic_set_media_detect()
1452 err = self->aq_fw_ops->set_media_detect(self->aq_hw, !!val); in aq_nic_set_media_detect()
1453 mutex_unlock(&self->fwreq_mutex); in aq_nic_set_media_detect()
1462 int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 tcs, u8 *prio_tc_map) in aq_nic_setup_tc_mqprio() argument
1464 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_setup_tc_mqprio()
1476 ndev_running = netif_running(self->ndev); in aq_nic_setup_tc_mqprio()
1478 dev_close(self->ndev); in aq_nic_setup_tc_mqprio()
1492 netdev_warn(self->ndev, "%s\n", in aq_nic_setup_tc_mqprio()
1495 netdev_set_num_tc(self->ndev, cfg->tcs); in aq_nic_setup_tc_mqprio()
1498 aq_nic_cfg_update_num_vecs(self); in aq_nic_setup_tc_mqprio()
1500 err = aq_nic_realloc_vectors(self); in aq_nic_setup_tc_mqprio()
1506 err = dev_open(self->ndev, NULL); in aq_nic_setup_tc_mqprio()
1512 int aq_nic_setup_tc_max_rate(struct aq_nic_s *self, const unsigned int tc, in aq_nic_setup_tc_max_rate() argument
1515 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_setup_tc_max_rate()
1521 netdev_warn(self->ndev, in aq_nic_setup_tc_max_rate()
1532 int aq_nic_setup_tc_min_rate(struct aq_nic_s *self, const unsigned int tc, in aq_nic_setup_tc_min_rate() argument
1535 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; in aq_nic_setup_tc_min_rate()
1546 netdev_warn(self->ndev, in aq_nic_setup_tc_min_rate()