Lines Matching full:nic

24 #include "nic.h"
61 MODULE_DESCRIPTION("Cavium Thunder NIC Virtual Function Driver");
75 static inline u8 nicvf_netdev_qidx(struct nicvf *nic, u8 qidx) in nicvf_netdev_qidx() argument
77 if (nic->sqs_mode) in nicvf_netdev_qidx()
78 return qidx + ((nic->sqs_id + 1) * MAX_CMP_QUEUES_PER_QS); in nicvf_netdev_qidx()
93 void nicvf_reg_write(struct nicvf *nic, u64 offset, u64 val) in nicvf_reg_write() argument
95 writeq_relaxed(val, nic->reg_base + offset); in nicvf_reg_write()
98 u64 nicvf_reg_read(struct nicvf *nic, u64 offset) in nicvf_reg_read() argument
100 return readq_relaxed(nic->reg_base + offset); in nicvf_reg_read()
103 void nicvf_queue_reg_write(struct nicvf *nic, u64 offset, in nicvf_queue_reg_write() argument
106 void __iomem *addr = nic->reg_base + offset; in nicvf_queue_reg_write()
111 u64 nicvf_queue_reg_read(struct nicvf *nic, u64 offset, u64 qidx) in nicvf_queue_reg_read() argument
113 void __iomem *addr = nic->reg_base + offset; in nicvf_queue_reg_read()
119 static void nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx) in nicvf_write_to_mbx() argument
123 nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]); in nicvf_write_to_mbx()
124 nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]); in nicvf_write_to_mbx()
127 int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx) in nicvf_send_msg_to_pf() argument
132 mutex_lock(&nic->rx_mode_mtx); in nicvf_send_msg_to_pf()
134 nic->pf_acked = false; in nicvf_send_msg_to_pf()
135 nic->pf_nacked = false; in nicvf_send_msg_to_pf()
137 nicvf_write_to_mbx(nic, mbx); in nicvf_send_msg_to_pf()
141 while (!nic->pf_acked) { in nicvf_send_msg_to_pf()
142 if (nic->pf_nacked) { in nicvf_send_msg_to_pf()
143 netdev_err(nic->netdev, in nicvf_send_msg_to_pf()
145 (mbx->msg.msg & 0xFF), nic->vf_id); in nicvf_send_msg_to_pf()
150 if (nic->pf_acked) in nicvf_send_msg_to_pf()
153 netdev_err(nic->netdev, in nicvf_send_msg_to_pf()
155 (mbx->msg.msg & 0xFF), nic->vf_id); in nicvf_send_msg_to_pf()
160 mutex_unlock(&nic->rx_mode_mtx); in nicvf_send_msg_to_pf()
167 static int nicvf_check_pf_ready(struct nicvf *nic) in nicvf_check_pf_ready() argument
172 if (nicvf_send_msg_to_pf(nic, &mbx)) { in nicvf_check_pf_ready()
173 netdev_err(nic->netdev, in nicvf_check_pf_ready()
181 static void nicvf_send_cfg_done(struct nicvf *nic) in nicvf_send_cfg_done() argument
186 if (nicvf_send_msg_to_pf(nic, &mbx)) { in nicvf_send_cfg_done()
187 netdev_err(nic->netdev, in nicvf_send_cfg_done()
192 static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx) in nicvf_read_bgx_stats() argument
195 nic->bgx_stats.rx_stats[bgx->idx] = bgx->stats; in nicvf_read_bgx_stats()
197 nic->bgx_stats.tx_stats[bgx->idx] = bgx->stats; in nicvf_read_bgx_stats()
200 static void nicvf_handle_mbx_intr(struct nicvf *nic) in nicvf_handle_mbx_intr() argument
211 *mbx_data = nicvf_reg_read(nic, mbx_addr); in nicvf_handle_mbx_intr()
216 netdev_dbg(nic->netdev, "Mbox message: msg: 0x%x\n", mbx.msg.msg); in nicvf_handle_mbx_intr()
219 nic->pf_acked = true; in nicvf_handle_mbx_intr()
220 nic->vf_id = mbx.nic_cfg.vf_id & 0x7F; in nicvf_handle_mbx_intr()
221 nic->tns_mode = mbx.nic_cfg.tns_mode & 0x7F; in nicvf_handle_mbx_intr()
222 nic->node = mbx.nic_cfg.node_id; in nicvf_handle_mbx_intr()
223 if (!nic->set_mac_pending) in nicvf_handle_mbx_intr()
224 eth_hw_addr_set(nic->netdev, mbx.nic_cfg.mac_addr); in nicvf_handle_mbx_intr()
225 nic->sqs_mode = mbx.nic_cfg.sqs_mode; in nicvf_handle_mbx_intr()
226 nic->loopback_supported = mbx.nic_cfg.loopback_supported; in nicvf_handle_mbx_intr()
227 nic->link_up = false; in nicvf_handle_mbx_intr()
228 nic->duplex = 0; in nicvf_handle_mbx_intr()
229 nic->speed = 0; in nicvf_handle_mbx_intr()
232 nic->pf_acked = true; in nicvf_handle_mbx_intr()
235 nic->pf_nacked = true; in nicvf_handle_mbx_intr()
238 nic->rss_info.rss_size = mbx.rss_size.ind_tbl_size; in nicvf_handle_mbx_intr()
239 nic->pf_acked = true; in nicvf_handle_mbx_intr()
242 nicvf_read_bgx_stats(nic, &mbx.bgx_stats); in nicvf_handle_mbx_intr()
243 nic->pf_acked = true; in nicvf_handle_mbx_intr()
246 nic->pf_acked = true; in nicvf_handle_mbx_intr()
247 if (nic->link_up != mbx.link_status.link_up) { in nicvf_handle_mbx_intr()
248 nic->link_up = mbx.link_status.link_up; in nicvf_handle_mbx_intr()
249 nic->duplex = mbx.link_status.duplex; in nicvf_handle_mbx_intr()
250 nic->speed = mbx.link_status.speed; in nicvf_handle_mbx_intr()
251 nic->mac_type = mbx.link_status.mac_type; in nicvf_handle_mbx_intr()
252 if (nic->link_up) { in nicvf_handle_mbx_intr()
253 netdev_info(nic->netdev, in nicvf_handle_mbx_intr()
255 nic->speed, in nicvf_handle_mbx_intr()
256 nic->duplex == DUPLEX_FULL ? in nicvf_handle_mbx_intr()
258 netif_carrier_on(nic->netdev); in nicvf_handle_mbx_intr()
259 netif_tx_start_all_queues(nic->netdev); in nicvf_handle_mbx_intr()
261 netdev_info(nic->netdev, "Link is Down\n"); in nicvf_handle_mbx_intr()
262 netif_carrier_off(nic->netdev); in nicvf_handle_mbx_intr()
263 netif_tx_stop_all_queues(nic->netdev); in nicvf_handle_mbx_intr()
268 nic->sqs_count = mbx.sqs_alloc.qs_count; in nicvf_handle_mbx_intr()
269 nic->pf_acked = true; in nicvf_handle_mbx_intr()
275 nic->snicvf[mbx.nicvf.sqs_id] = in nicvf_handle_mbx_intr()
277 nic->pf_acked = true; in nicvf_handle_mbx_intr()
284 nic->pnicvf = (struct nicvf *)mbx.nicvf.nicvf; in nicvf_handle_mbx_intr()
285 nic->pf_acked = true; in nicvf_handle_mbx_intr()
288 nic->pfc.autoneg = mbx.pfc.autoneg; in nicvf_handle_mbx_intr()
289 nic->pfc.fc_rx = mbx.pfc.fc_rx; in nicvf_handle_mbx_intr()
290 nic->pfc.fc_tx = mbx.pfc.fc_tx; in nicvf_handle_mbx_intr()
291 nic->pf_acked = true; in nicvf_handle_mbx_intr()
294 netdev_err(nic->netdev, in nicvf_handle_mbx_intr()
298 nicvf_clear_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_handle_mbx_intr()
301 static int nicvf_hw_set_mac_addr(struct nicvf *nic, struct net_device *netdev) in nicvf_hw_set_mac_addr() argument
306 mbx.mac.vf_id = nic->vf_id; in nicvf_hw_set_mac_addr()
309 return nicvf_send_msg_to_pf(nic, &mbx); in nicvf_hw_set_mac_addr()
312 static void nicvf_config_cpi(struct nicvf *nic) in nicvf_config_cpi() argument
317 mbx.cpi_cfg.vf_id = nic->vf_id; in nicvf_config_cpi()
318 mbx.cpi_cfg.cpi_alg = nic->cpi_alg; in nicvf_config_cpi()
319 mbx.cpi_cfg.rq_cnt = nic->qs->rq_cnt; in nicvf_config_cpi()
321 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_config_cpi()
324 static void nicvf_get_rss_size(struct nicvf *nic) in nicvf_get_rss_size() argument
329 mbx.rss_size.vf_id = nic->vf_id; in nicvf_get_rss_size()
330 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_get_rss_size()
333 void nicvf_config_rss(struct nicvf *nic) in nicvf_config_rss() argument
336 struct nicvf_rss_info *rss = &nic->rss_info; in nicvf_config_rss()
340 mbx.rss_cfg.vf_id = nic->vf_id; in nicvf_config_rss()
352 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_config_rss()
358 void nicvf_set_rss_key(struct nicvf *nic) in nicvf_set_rss_key() argument
360 struct nicvf_rss_info *rss = &nic->rss_info; in nicvf_set_rss_key()
365 nicvf_reg_write(nic, key_addr, rss->key[idx]); in nicvf_set_rss_key()
370 static int nicvf_rss_init(struct nicvf *nic) in nicvf_rss_init() argument
372 struct nicvf_rss_info *rss = &nic->rss_info; in nicvf_rss_init()
375 nicvf_get_rss_size(nic); in nicvf_rss_init()
386 nicvf_set_rss_key(nic); in nicvf_rss_init()
389 nicvf_reg_write(nic, NIC_VNIC_RSS_CFG, rss->cfg); in nicvf_rss_init()
395 nic->rx_queues); in nicvf_rss_init()
396 nicvf_config_rss(nic); in nicvf_rss_init()
401 static void nicvf_request_sqs(struct nicvf *nic) in nicvf_request_sqs() argument
405 int sqs_count = nic->sqs_count; in nicvf_request_sqs()
409 if (nic->sqs_mode || !nic->sqs_count) in nicvf_request_sqs()
413 mbx.sqs_alloc.vf_id = nic->vf_id; in nicvf_request_sqs()
414 mbx.sqs_alloc.qs_count = nic->sqs_count; in nicvf_request_sqs()
415 if (nicvf_send_msg_to_pf(nic, &mbx)) { in nicvf_request_sqs()
417 nic->sqs_count = 0; in nicvf_request_sqs()
422 if (!nic->sqs_count) in nicvf_request_sqs()
425 if (nic->rx_queues > MAX_RCV_QUEUES_PER_QS) in nicvf_request_sqs()
426 rx_queues = nic->rx_queues - MAX_RCV_QUEUES_PER_QS; in nicvf_request_sqs()
428 tx_queues = nic->tx_queues + nic->xdp_tx_queues; in nicvf_request_sqs()
433 for (sqs = 0; sqs < nic->sqs_count; sqs++) { in nicvf_request_sqs()
435 mbx.nicvf.vf_id = nic->vf_id; in nicvf_request_sqs()
437 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_request_sqs()
439 nic->snicvf[sqs]->sqs_id = sqs; in nicvf_request_sqs()
441 nic->snicvf[sqs]->qs->rq_cnt = MAX_RCV_QUEUES_PER_QS; in nicvf_request_sqs()
444 nic->snicvf[sqs]->qs->rq_cnt = rx_queues; in nicvf_request_sqs()
449 nic->snicvf[sqs]->qs->sq_cnt = MAX_SND_QUEUES_PER_QS; in nicvf_request_sqs()
452 nic->snicvf[sqs]->qs->sq_cnt = tx_queues; in nicvf_request_sqs()
456 nic->snicvf[sqs]->qs->cq_cnt = in nicvf_request_sqs()
457 max(nic->snicvf[sqs]->qs->rq_cnt, nic->snicvf[sqs]->qs->sq_cnt); in nicvf_request_sqs()
460 nicvf_open(nic->snicvf[sqs]->netdev); in nicvf_request_sqs()
464 if (sqs_count != nic->sqs_count) in nicvf_request_sqs()
465 nicvf_set_real_num_queues(nic->netdev, in nicvf_request_sqs()
466 nic->tx_queues, nic->rx_queues); in nicvf_request_sqs()
473 static void nicvf_send_vf_struct(struct nicvf *nic) in nicvf_send_vf_struct() argument
478 mbx.nicvf.sqs_mode = nic->sqs_mode; in nicvf_send_vf_struct()
479 mbx.nicvf.nicvf = (u64)nic; in nicvf_send_vf_struct()
480 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_send_vf_struct()
483 static void nicvf_get_primary_vf_struct(struct nicvf *nic) in nicvf_get_primary_vf_struct() argument
488 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_get_primary_vf_struct()
510 static int nicvf_init_resources(struct nicvf *nic) in nicvf_init_resources() argument
515 nicvf_qset_config(nic, true); in nicvf_init_resources()
518 err = nicvf_config_data_transfer(nic, true); in nicvf_init_resources()
520 netdev_err(nic->netdev, in nicvf_init_resources()
528 static inline bool nicvf_xdp_rx(struct nicvf *nic, struct bpf_prog *prog, in nicvf_xdp_rx() argument
544 cpu_addr = nicvf_iova_to_phys(nic, dma_addr); in nicvf_xdp_rx()
575 dma_unmap_page_attrs(&nic->pdev->dev, dma_addr, in nicvf_xdp_rx()
590 nicvf_xdp_sq_append_pkt(nic, sq, (u64)xdp.data, dma_addr, len); in nicvf_xdp_rx()
593 bpf_warn_invalid_xdp_action(nic->netdev, prog, action); in nicvf_xdp_rx()
596 trace_xdp_exception(nic->netdev, prog, action); in nicvf_xdp_rx()
606 dma_unmap_page_attrs(&nic->pdev->dev, dma_addr, in nicvf_xdp_rx()
620 struct nicvf *nic = netdev_priv(netdev); in nicvf_snd_ptp_handler() local
624 nic = nic->pnicvf; in nicvf_snd_ptp_handler()
630 atomic_set(&nic->tx_ptp_skbs, 0); in nicvf_snd_ptp_handler()
633 if (!nic->ptp_skb) in nicvf_snd_ptp_handler()
643 ns = cavium_ptp_tstamp2time(nic->ptp_clock, cqe_tx->ptp_timestamp); in nicvf_snd_ptp_handler()
645 skb_tstamp_tx(nic->ptp_skb, &ts); in nicvf_snd_ptp_handler()
649 dev_kfree_skb_any(nic->ptp_skb); in nicvf_snd_ptp_handler()
650 nic->ptp_skb = NULL; in nicvf_snd_ptp_handler()
662 struct nicvf *nic = netdev_priv(netdev); in nicvf_snd_pkt_handler() local
667 sq = &nic->qs->sq[cqe_tx->sq_idx]; in nicvf_snd_pkt_handler()
675 nicvf_check_cqe_tx_errs(nic->pnicvf, cqe_tx); in nicvf_snd_pkt_handler()
682 nicvf_unmap_sndq_buffers(nic, sq, cqe_tx->sqe_ptr, in nicvf_snd_pkt_handler()
700 nicvf_unmap_sndq_buffers(nic, sq, hdr->rsvd2, in nicvf_snd_pkt_handler()
704 nicvf_unmap_sndq_buffers(nic, sq, cqe_tx->sqe_ptr, in nicvf_snd_pkt_handler()
713 !nic->pnicvf->ptp_skb) in nicvf_snd_pkt_handler()
714 nic->pnicvf->ptp_skb = skb; in nicvf_snd_pkt_handler()
722 if (!nic->hw_tso) in nicvf_snd_pkt_handler()
755 static inline void nicvf_set_rxtstamp(struct nicvf *nic, struct sk_buff *skb) in nicvf_set_rxtstamp() argument
759 if (!nic->ptp_clock || !nic->hw_rx_tstamp) in nicvf_set_rxtstamp()
763 ns = cavium_ptp_tstamp2time(nic->ptp_clock, in nicvf_set_rxtstamp()
776 struct nicvf *nic = netdev_priv(netdev); in nicvf_rcv_pkt_handler() local
777 struct nicvf *snic = nic; in nicvf_rcv_pkt_handler()
781 rq_idx = nicvf_netdev_qidx(nic, cqe_rx->rq_idx); in nicvf_rcv_pkt_handler()
783 if (nic->sqs_mode) { in nicvf_rcv_pkt_handler()
785 nic = nic->pnicvf; in nicvf_rcv_pkt_handler()
786 netdev = nic->netdev; in nicvf_rcv_pkt_handler()
791 err = nicvf_check_cqe_rx_errs(nic, cqe_rx); in nicvf_rcv_pkt_handler()
797 if (nic->xdp_prog && (cqe_rx->rb_cnt == 1)) { in nicvf_rcv_pkt_handler()
799 if (nicvf_xdp_rx(snic, nic->xdp_prog, cqe_rx, sq, rq, &skb)) in nicvf_rcv_pkt_handler()
803 nic->xdp_prog ? true : false); in nicvf_rcv_pkt_handler()
809 if (netif_msg_pktdata(nic)) { in nicvf_rcv_pkt_handler()
810 netdev_info(nic->netdev, "skb 0x%p, len=%d\n", skb, skb->len); in nicvf_rcv_pkt_handler()
821 nicvf_set_rxtstamp(nic, skb); in nicvf_rcv_pkt_handler()
851 struct nicvf *nic = netdev_priv(netdev); in nicvf_cq_intr_handler() local
852 struct queue_set *qs = nic->qs; in nicvf_cq_intr_handler()
864 cqe_count = nicvf_queue_reg_read(nic, NIC_QSET_CQ_0_7_STATUS, cq_idx); in nicvf_cq_intr_handler()
870 cqe_head = nicvf_queue_reg_read(nic, NIC_QSET_CQ_0_7_HEAD, cq_idx) >> 9; in nicvf_cq_intr_handler()
910 nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_DOOR, in nicvf_cq_intr_handler()
921 txq_idx = nicvf_netdev_qidx(nic, cq_idx); in nicvf_cq_intr_handler()
923 if (nic->pnicvf->xdp_prog) { in nicvf_cq_intr_handler()
924 if (txq_idx < nic->pnicvf->xdp_tx_queues) { in nicvf_cq_intr_handler()
925 nicvf_xdp_sq_doorbell(nic, sq, cq_idx); in nicvf_cq_intr_handler()
928 nic = nic->pnicvf; in nicvf_cq_intr_handler()
929 txq_idx -= nic->pnicvf->xdp_tx_queues; in nicvf_cq_intr_handler()
935 netdev = nic->pnicvf->netdev; in nicvf_cq_intr_handler()
944 nic = nic->pnicvf; in nicvf_cq_intr_handler()
945 this_cpu_inc(nic->drv_stats->txq_wake); in nicvf_cq_intr_handler()
946 netif_warn(nic, tx_err, netdev, in nicvf_cq_intr_handler()
961 struct nicvf *nic = netdev_priv(netdev); in nicvf_poll() local
971 cq_head = nicvf_queue_reg_read(nic, NIC_QSET_CQ_0_7_HEAD, in nicvf_poll()
973 nicvf_clear_intr(nic, NICVF_INTR_CQ, cq->cq_idx); in nicvf_poll()
974 nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_HEAD, in nicvf_poll()
976 nicvf_enable_intr(nic, NICVF_INTR_CQ, cq->cq_idx); in nicvf_poll()
987 struct nicvf *nic = from_tasklet(nic, t, qs_err_task); in nicvf_handle_qs_err() local
988 struct queue_set *qs = nic->qs; in nicvf_handle_qs_err()
992 netif_tx_disable(nic->netdev); in nicvf_handle_qs_err()
996 status = nicvf_queue_reg_read(nic, NIC_QSET_CQ_0_7_STATUS, in nicvf_handle_qs_err()
1001 nicvf_disable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_handle_qs_err()
1002 nicvf_sq_disable(nic, qidx); in nicvf_handle_qs_err()
1003 nicvf_cq_intr_handler(nic->netdev, qidx, NULL, 0); in nicvf_handle_qs_err()
1004 nicvf_cmp_queue_config(nic, qs, qidx, true); in nicvf_handle_qs_err()
1005 nicvf_sq_free_used_descs(nic->netdev, &qs->sq[qidx], qidx); in nicvf_handle_qs_err()
1006 nicvf_sq_enable(nic, &qs->sq[qidx], qidx); in nicvf_handle_qs_err()
1008 nicvf_enable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_handle_qs_err()
1011 netif_tx_start_all_queues(nic->netdev); in nicvf_handle_qs_err()
1013 nicvf_enable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_handle_qs_err()
1016 static void nicvf_dump_intr_status(struct nicvf *nic) in nicvf_dump_intr_status() argument
1018 netif_info(nic, intr, nic->netdev, "interrupt status 0x%llx\n", in nicvf_dump_intr_status()
1019 nicvf_reg_read(nic, NIC_VF_INT)); in nicvf_dump_intr_status()
1024 struct nicvf *nic = (struct nicvf *)nicvf_irq; in nicvf_misc_intr_handler() local
1027 nicvf_dump_intr_status(nic); in nicvf_misc_intr_handler()
1029 intr = nicvf_reg_read(nic, NIC_VF_INT); in nicvf_misc_intr_handler()
1034 nicvf_handle_mbx_intr(nic); in nicvf_misc_intr_handler()
1042 struct nicvf *nic = cq_poll->nicvf; in nicvf_intr_handler() local
1045 nicvf_dump_intr_status(nic); in nicvf_intr_handler()
1048 nicvf_disable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_intr_handler()
1054 nicvf_clear_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_intr_handler()
1061 struct nicvf *nic = (struct nicvf *)nicvf_irq; in nicvf_rbdr_intr_handler() local
1065 nicvf_dump_intr_status(nic); in nicvf_rbdr_intr_handler()
1068 for (qidx = 0; qidx < nic->qs->rbdr_cnt; qidx++) { in nicvf_rbdr_intr_handler()
1069 if (!nicvf_is_intr_enabled(nic, NICVF_INTR_RBDR, qidx)) in nicvf_rbdr_intr_handler()
1071 nicvf_disable_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_rbdr_intr_handler()
1072 tasklet_hi_schedule(&nic->rbdr_task); in nicvf_rbdr_intr_handler()
1074 nicvf_clear_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_rbdr_intr_handler()
1082 struct nicvf *nic = (struct nicvf *)nicvf_irq; in nicvf_qs_err_intr_handler() local
1084 nicvf_dump_intr_status(nic); in nicvf_qs_err_intr_handler()
1087 nicvf_disable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_qs_err_intr_handler()
1088 tasklet_hi_schedule(&nic->qs_err_task); in nicvf_qs_err_intr_handler()
1089 nicvf_clear_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_qs_err_intr_handler()
1094 static void nicvf_set_irq_affinity(struct nicvf *nic) in nicvf_set_irq_affinity() argument
1098 for (vec = 0; vec < nic->num_vec; vec++) { in nicvf_set_irq_affinity()
1099 if (!nic->irq_allocated[vec]) in nicvf_set_irq_affinity()
1102 if (!zalloc_cpumask_var(&nic->affinity_mask[vec], GFP_KERNEL)) in nicvf_set_irq_affinity()
1107 cpu = nicvf_netdev_qidx(nic, vec) + 1; in nicvf_set_irq_affinity()
1111 cpumask_set_cpu(cpumask_local_spread(cpu, nic->node), in nicvf_set_irq_affinity()
1112 nic->affinity_mask[vec]); in nicvf_set_irq_affinity()
1113 irq_set_affinity_hint(pci_irq_vector(nic->pdev, vec), in nicvf_set_irq_affinity()
1114 nic->affinity_mask[vec]); in nicvf_set_irq_affinity()
1118 static int nicvf_register_interrupts(struct nicvf *nic) in nicvf_register_interrupts() argument
1123 sprintf(nic->irq_name[irq], "%s-rxtx-%d", in nicvf_register_interrupts()
1124 nic->pnicvf->netdev->name, in nicvf_register_interrupts()
1125 nicvf_netdev_qidx(nic, irq)); in nicvf_register_interrupts()
1128 sprintf(nic->irq_name[irq], "%s-sq-%d", in nicvf_register_interrupts()
1129 nic->pnicvf->netdev->name, in nicvf_register_interrupts()
1130 nicvf_netdev_qidx(nic, irq - NICVF_INTR_ID_SQ)); in nicvf_register_interrupts()
1133 sprintf(nic->irq_name[irq], "%s-rbdr-%d", in nicvf_register_interrupts()
1134 nic->pnicvf->netdev->name, in nicvf_register_interrupts()
1135 nic->sqs_mode ? (nic->sqs_id + 1) : 0); in nicvf_register_interrupts()
1138 for (irq = 0; irq < nic->qs->cq_cnt; irq++) { in nicvf_register_interrupts()
1139 ret = request_irq(pci_irq_vector(nic->pdev, irq), in nicvf_register_interrupts()
1141 0, nic->irq_name[irq], nic->napi[irq]); in nicvf_register_interrupts()
1144 nic->irq_allocated[irq] = true; in nicvf_register_interrupts()
1149 irq < (NICVF_INTR_ID_RBDR + nic->qs->rbdr_cnt); irq++) { in nicvf_register_interrupts()
1150 ret = request_irq(pci_irq_vector(nic->pdev, irq), in nicvf_register_interrupts()
1152 0, nic->irq_name[irq], nic); in nicvf_register_interrupts()
1155 nic->irq_allocated[irq] = true; in nicvf_register_interrupts()
1159 sprintf(nic->irq_name[NICVF_INTR_ID_QS_ERR], "%s-qset-err-%d", in nicvf_register_interrupts()
1160 nic->pnicvf->netdev->name, in nicvf_register_interrupts()
1161 nic->sqs_mode ? (nic->sqs_id + 1) : 0); in nicvf_register_interrupts()
1163 ret = request_irq(pci_irq_vector(nic->pdev, irq), in nicvf_register_interrupts()
1165 0, nic->irq_name[irq], nic); in nicvf_register_interrupts()
1169 nic->irq_allocated[irq] = true; in nicvf_register_interrupts()
1172 nicvf_set_irq_affinity(nic); in nicvf_register_interrupts()
1176 netdev_err(nic->netdev, "request_irq failed, vector %d\n", irq); in nicvf_register_interrupts()
1181 static void nicvf_unregister_interrupts(struct nicvf *nic) in nicvf_unregister_interrupts() argument
1183 struct pci_dev *pdev = nic->pdev; in nicvf_unregister_interrupts()
1187 for (irq = 0; irq < nic->num_vec; irq++) { in nicvf_unregister_interrupts()
1188 if (!nic->irq_allocated[irq]) in nicvf_unregister_interrupts()
1192 free_cpumask_var(nic->affinity_mask[irq]); in nicvf_unregister_interrupts()
1195 free_irq(pci_irq_vector(pdev, irq), nic->napi[irq]); in nicvf_unregister_interrupts()
1197 free_irq(pci_irq_vector(pdev, irq), nic); in nicvf_unregister_interrupts()
1199 nic->irq_allocated[irq] = false; in nicvf_unregister_interrupts()
1204 nic->num_vec = 0; in nicvf_unregister_interrupts()
1210 static int nicvf_register_misc_interrupt(struct nicvf *nic) in nicvf_register_misc_interrupt() argument
1216 if (nic->pdev->msix_enabled) in nicvf_register_misc_interrupt()
1220 nic->num_vec = pci_msix_vec_count(nic->pdev); in nicvf_register_misc_interrupt()
1221 ret = pci_alloc_irq_vectors(nic->pdev, nic->num_vec, nic->num_vec, in nicvf_register_misc_interrupt()
1224 netdev_err(nic->netdev, in nicvf_register_misc_interrupt()
1225 "Req for #%d msix vectors failed\n", nic->num_vec); in nicvf_register_misc_interrupt()
1229 sprintf(nic->irq_name[irq], "%s Mbox", "NICVF"); in nicvf_register_misc_interrupt()
1231 ret = request_irq(pci_irq_vector(nic->pdev, irq), in nicvf_register_misc_interrupt()
1232 nicvf_misc_intr_handler, 0, nic->irq_name[irq], nic); in nicvf_register_misc_interrupt()
1236 nic->irq_allocated[irq] = true; in nicvf_register_misc_interrupt()
1239 nicvf_enable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_register_misc_interrupt()
1242 if (!nicvf_check_pf_ready(nic)) { in nicvf_register_misc_interrupt()
1243 nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_register_misc_interrupt()
1244 nicvf_unregister_interrupts(nic); in nicvf_register_misc_interrupt()
1253 struct nicvf *nic = netdev_priv(netdev); in nicvf_xmit() local
1270 if (nic->xdp_prog) in nicvf_xmit()
1271 qid += nic->xdp_tx_queues; in nicvf_xmit()
1273 snic = nic; in nicvf_xmit()
1277 snic = (struct nicvf *)nic->snicvf[tmp - 1]; in nicvf_xmit()
1279 netdev_warn(nic->netdev, in nicvf_xmit()
1300 this_cpu_inc(nic->drv_stats->txq_stop); in nicvf_xmit()
1301 netif_warn(nic, tx_err, netdev, in nicvf_xmit()
1310 static inline void nicvf_free_cq_poll(struct nicvf *nic) in nicvf_free_cq_poll() argument
1315 for (qidx = 0; qidx < nic->qs->cq_cnt; qidx++) { in nicvf_free_cq_poll()
1316 cq_poll = nic->napi[qidx]; in nicvf_free_cq_poll()
1319 nic->napi[qidx] = NULL; in nicvf_free_cq_poll()
1327 struct nicvf *nic = netdev_priv(netdev); in nicvf_stop() local
1328 struct queue_set *qs = nic->qs; in nicvf_stop()
1333 if (nic->nicvf_rx_mode_wq) { in nicvf_stop()
1334 cancel_delayed_work_sync(&nic->link_change_work); in nicvf_stop()
1335 drain_workqueue(nic->nicvf_rx_mode_wq); in nicvf_stop()
1339 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_stop()
1342 netif_tx_stop_all_queues(nic->netdev); in nicvf_stop()
1343 nic->link_up = false; in nicvf_stop()
1346 if (!nic->sqs_mode) { in nicvf_stop()
1347 for (qidx = 0; qidx < nic->sqs_count; qidx++) { in nicvf_stop()
1348 if (!nic->snicvf[qidx]) in nicvf_stop()
1350 nicvf_stop(nic->snicvf[qidx]->netdev); in nicvf_stop()
1351 nic->snicvf[qidx] = NULL; in nicvf_stop()
1357 nicvf_disable_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_stop()
1358 nicvf_clear_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_stop()
1360 nicvf_disable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_stop()
1361 nicvf_clear_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_stop()
1364 for (irq = 0; irq < nic->num_vec; irq++) in nicvf_stop()
1365 synchronize_irq(pci_irq_vector(nic->pdev, irq)); in nicvf_stop()
1367 tasklet_kill(&nic->rbdr_task); in nicvf_stop()
1368 tasklet_kill(&nic->qs_err_task); in nicvf_stop()
1369 if (nic->rb_work_scheduled) in nicvf_stop()
1370 cancel_delayed_work_sync(&nic->rbdr_work); in nicvf_stop()
1372 for (qidx = 0; qidx < nic->qs->cq_cnt; qidx++) { in nicvf_stop()
1373 cq_poll = nic->napi[qidx]; in nicvf_stop()
1380 nicvf_disable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_stop()
1381 nicvf_clear_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_stop()
1392 nicvf_config_data_transfer(nic, false); in nicvf_stop()
1395 nicvf_qset_config(nic, false); in nicvf_stop()
1398 nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_stop()
1400 nicvf_unregister_interrupts(nic); in nicvf_stop()
1402 nicvf_free_cq_poll(nic); in nicvf_stop()
1405 if (nic->ptp_skb) { in nicvf_stop()
1406 dev_kfree_skb_any(nic->ptp_skb); in nicvf_stop()
1407 nic->ptp_skb = NULL; in nicvf_stop()
1411 nic->pnicvf = nic; in nicvf_stop()
1416 static int nicvf_config_hw_rx_tstamp(struct nicvf *nic, bool enable) in nicvf_config_hw_rx_tstamp() argument
1423 return nicvf_send_msg_to_pf(nic, &mbx); in nicvf_config_hw_rx_tstamp()
1426 static int nicvf_update_hw_max_frs(struct nicvf *nic, int mtu) in nicvf_update_hw_max_frs() argument
1432 mbx.frs.vf_id = nic->vf_id; in nicvf_update_hw_max_frs()
1434 return nicvf_send_msg_to_pf(nic, &mbx); in nicvf_update_hw_max_frs()
1439 struct nicvf *nic = container_of(work_arg, in nicvf_link_status_check_task() local
1444 nicvf_send_msg_to_pf(nic, &mbx); in nicvf_link_status_check_task()
1445 queue_delayed_work(nic->nicvf_rx_mode_wq, in nicvf_link_status_check_task()
1446 &nic->link_change_work, 2 * HZ); in nicvf_link_status_check_task()
1452 struct nicvf *nic = netdev_priv(netdev); in nicvf_open() local
1453 struct queue_set *qs = nic->qs; in nicvf_open()
1457 if (nic->nicvf_rx_mode_wq) in nicvf_open()
1458 drain_workqueue(nic->nicvf_rx_mode_wq); in nicvf_open()
1462 err = nicvf_register_misc_interrupt(nic); in nicvf_open()
1474 cq_poll->nicvf = nic; in nicvf_open()
1477 nic->napi[qidx] = cq_poll; in nicvf_open()
1481 if (!nic->sqs_mode && is_zero_ether_addr(netdev->dev_addr)) { in nicvf_open()
1483 nicvf_hw_set_mac_addr(nic, netdev); in nicvf_open()
1486 if (nic->set_mac_pending) { in nicvf_open()
1487 nic->set_mac_pending = false; in nicvf_open()
1488 nicvf_hw_set_mac_addr(nic, netdev); in nicvf_open()
1492 tasklet_setup(&nic->qs_err_task, nicvf_handle_qs_err); in nicvf_open()
1495 tasklet_setup(&nic->rbdr_task, nicvf_rbdr_task); in nicvf_open()
1496 INIT_DELAYED_WORK(&nic->rbdr_work, nicvf_rbdr_work); in nicvf_open()
1499 nic->cpi_alg = cpi_alg; in nicvf_open()
1500 if (!nic->sqs_mode) in nicvf_open()
1501 nicvf_config_cpi(nic); in nicvf_open()
1503 nicvf_request_sqs(nic); in nicvf_open()
1504 if (nic->sqs_mode) in nicvf_open()
1505 nicvf_get_primary_vf_struct(nic); in nicvf_open()
1508 if (nic->ptp_clock) in nicvf_open()
1509 nicvf_config_hw_rx_tstamp(nic, nic->hw_rx_tstamp); in nicvf_open()
1510 atomic_set(&nic->tx_ptp_skbs, 0); in nicvf_open()
1511 nic->ptp_skb = NULL; in nicvf_open()
1514 if (!nic->sqs_mode) { in nicvf_open()
1515 nicvf_rss_init(nic); in nicvf_open()
1516 err = nicvf_update_hw_max_frs(nic, netdev->mtu); in nicvf_open()
1522 memset(per_cpu_ptr(nic->drv_stats, cpu), 0, in nicvf_open()
1526 err = nicvf_register_interrupts(nic); in nicvf_open()
1531 err = nicvf_init_resources(nic); in nicvf_open()
1538 nicvf_reg_write(nic, NIC_VF_INT, -1); in nicvf_open()
1540 nicvf_enable_intr(nic, NICVF_INTR_QS_ERR, 0); in nicvf_open()
1544 nicvf_enable_intr(nic, NICVF_INTR_CQ, qidx); in nicvf_open()
1548 nicvf_enable_intr(nic, NICVF_INTR_RBDR, qidx); in nicvf_open()
1551 nicvf_send_cfg_done(nic); in nicvf_open()
1553 if (nic->nicvf_rx_mode_wq) { in nicvf_open()
1554 INIT_DELAYED_WORK(&nic->link_change_work, in nicvf_open()
1556 queue_delayed_work(nic->nicvf_rx_mode_wq, in nicvf_open()
1557 &nic->link_change_work, 0); in nicvf_open()
1562 nicvf_disable_intr(nic, NICVF_INTR_MBOX, 0); in nicvf_open()
1563 nicvf_unregister_interrupts(nic); in nicvf_open()
1564 tasklet_kill(&nic->qs_err_task); in nicvf_open()
1565 tasklet_kill(&nic->rbdr_task); in nicvf_open()
1568 cq_poll = nic->napi[qidx]; in nicvf_open()
1574 nicvf_free_cq_poll(nic); in nicvf_open()
1580 struct nicvf *nic = netdev_priv(netdev); in nicvf_change_mtu() local
1586 if (nic->xdp_prog && new_mtu > MAX_XDP_MTU) { in nicvf_change_mtu()
1597 if (nicvf_update_hw_max_frs(nic, new_mtu)) { in nicvf_change_mtu()
1608 struct nicvf *nic = netdev_priv(netdev); in nicvf_set_mac_address() local
1615 if (nic->pdev->msix_enabled) { in nicvf_set_mac_address()
1616 if (nicvf_hw_set_mac_addr(nic, netdev)) in nicvf_set_mac_address()
1619 nic->set_mac_pending = true; in nicvf_set_mac_address()
1625 void nicvf_update_lmac_stats(struct nicvf *nic) in nicvf_update_lmac_stats() argument
1630 if (!netif_running(nic->netdev)) in nicvf_update_lmac_stats()
1634 mbx.bgx_stats.vf_id = nic->vf_id; in nicvf_update_lmac_stats()
1639 if (nicvf_send_msg_to_pf(nic, &mbx)) in nicvf_update_lmac_stats()
1650 if (nicvf_send_msg_to_pf(nic, &mbx)) in nicvf_update_lmac_stats()
1656 void nicvf_update_stats(struct nicvf *nic) in nicvf_update_stats() argument
1660 struct nicvf_hw_stats *stats = &nic->hw_stats; in nicvf_update_stats()
1662 struct queue_set *qs = nic->qs; in nicvf_update_stats()
1665 nicvf_reg_read(nic, NIC_VNIC_RX_STAT_0_13 | (reg << 3)) in nicvf_update_stats()
1667 nicvf_reg_read(nic, NIC_VNIC_TX_STAT_0_4 | (reg << 3)) in nicvf_update_stats()
1696 if (nic->t88 && nic->hw_tso) { in nicvf_update_stats()
1698 drv_stats = per_cpu_ptr(nic->drv_stats, cpu); in nicvf_update_stats()
1714 nicvf_update_rq_stats(nic, qidx); in nicvf_update_stats()
1716 nicvf_update_sq_stats(nic, qidx); in nicvf_update_stats()
1722 struct nicvf *nic = netdev_priv(netdev); in nicvf_get_stats64() local
1723 struct nicvf_hw_stats *hw_stats = &nic->hw_stats; in nicvf_get_stats64()
1725 nicvf_update_stats(nic); in nicvf_get_stats64()
1740 struct nicvf *nic = netdev_priv(dev); in nicvf_tx_timeout() local
1742 netif_warn(nic, tx_err, dev, "Transmit timed out, resetting\n"); in nicvf_tx_timeout()
1744 this_cpu_inc(nic->drv_stats->tx_timeout); in nicvf_tx_timeout()
1745 schedule_work(&nic->reset_task); in nicvf_tx_timeout()
1750 struct nicvf *nic; in nicvf_reset_task() local
1752 nic = container_of(work, struct nicvf, reset_task); in nicvf_reset_task()
1754 if (!netif_running(nic->netdev)) in nicvf_reset_task()
1757 nicvf_stop(nic->netdev); in nicvf_reset_task()
1758 nicvf_open(nic->netdev); in nicvf_reset_task()
1759 netif_trans_update(nic->netdev); in nicvf_reset_task()
1762 static int nicvf_config_loopback(struct nicvf *nic, in nicvf_config_loopback() argument
1768 mbx.lbk.vf_id = nic->vf_id; in nicvf_config_loopback()
1771 return nicvf_send_msg_to_pf(nic, &mbx); in nicvf_config_loopback()
1777 struct nicvf *nic = netdev_priv(netdev); in nicvf_fix_features() local
1780 netif_running(netdev) && !nic->loopback_supported) in nicvf_fix_features()
1789 struct nicvf *nic = netdev_priv(netdev); in nicvf_set_features() local
1793 nicvf_config_vlan_stripping(nic, features); in nicvf_set_features()
1796 return nicvf_config_loopback(nic, features); in nicvf_set_features()
1801 static void nicvf_set_xdp_queues(struct nicvf *nic, bool bpf_attached) in nicvf_set_xdp_queues() argument
1807 nic->xdp_tx_queues = 0; in nicvf_set_xdp_queues()
1809 nic->xdp_tx_queues = nic->rx_queues; in nicvf_set_xdp_queues()
1814 txq_count = nic->xdp_tx_queues + nic->tx_queues; in nicvf_set_xdp_queues()
1815 cq_count = max(nic->rx_queues, txq_count); in nicvf_set_xdp_queues()
1817 nic->sqs_count = roundup(cq_count, MAX_CMP_QUEUES_PER_QS); in nicvf_set_xdp_queues()
1818 nic->sqs_count = (nic->sqs_count / MAX_CMP_QUEUES_PER_QS) - 1; in nicvf_set_xdp_queues()
1820 nic->sqs_count = 0; in nicvf_set_xdp_queues()
1824 nic->qs->rq_cnt = min_t(u8, nic->rx_queues, MAX_RCV_QUEUES_PER_QS); in nicvf_set_xdp_queues()
1825 nic->qs->sq_cnt = min_t(u8, txq_count, MAX_SND_QUEUES_PER_QS); in nicvf_set_xdp_queues()
1826 nic->qs->cq_cnt = max_t(u8, nic->qs->rq_cnt, nic->qs->sq_cnt); in nicvf_set_xdp_queues()
1829 nicvf_set_real_num_queues(nic->netdev, nic->tx_queues, nic->rx_queues); in nicvf_set_xdp_queues()
1832 static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog) in nicvf_xdp_setup() argument
1834 struct net_device *dev = nic->netdev; in nicvf_xdp_setup()
1835 bool if_up = netif_running(nic->netdev); in nicvf_xdp_setup()
1856 if ((nic->rx_queues + nic->tx_queues) > nic->max_queues) { in nicvf_xdp_setup()
1859 nic->max_queues); in nicvf_xdp_setup()
1864 nicvf_stop(nic->netdev); in nicvf_xdp_setup()
1866 old_prog = xchg(&nic->xdp_prog, prog); in nicvf_xdp_setup()
1871 if (nic->xdp_prog) { in nicvf_xdp_setup()
1873 bpf_prog_add(nic->xdp_prog, nic->rx_queues - 1); in nicvf_xdp_setup()
1878 nicvf_set_xdp_queues(nic, bpf_attached); in nicvf_xdp_setup()
1882 nicvf_open(nic->netdev); in nicvf_xdp_setup()
1883 netif_trans_update(nic->netdev); in nicvf_xdp_setup()
1891 struct nicvf *nic = netdev_priv(netdev); in nicvf_xdp() local
1897 if (pass1_silicon(nic->pdev)) in nicvf_xdp()
1902 return nicvf_xdp_setup(nic, xdp->prog); in nicvf_xdp()
1911 struct nicvf *nic = netdev_priv(netdev); in nicvf_config_hwtstamp() local
1913 if (!nic->ptp_clock) in nicvf_config_hwtstamp()
1929 nic->hw_rx_tstamp = false; in nicvf_config_hwtstamp()
1945 nic->hw_rx_tstamp = true; in nicvf_config_hwtstamp()
1953 nicvf_config_hw_rx_tstamp(nic, nic->hw_rx_tstamp); in nicvf_config_hwtstamp()
1972 struct nicvf *nic) in __nicvf_set_rx_mode_task() argument
1985 if (nicvf_send_msg_to_pf(nic, &mbx) < 0) in __nicvf_set_rx_mode_task()
1994 if (nicvf_send_msg_to_pf(nic, &mbx) < 0) in __nicvf_set_rx_mode_task()
2004 if (nicvf_send_msg_to_pf(nic, &mbx) < 0) in __nicvf_set_rx_mode_task()
2013 nicvf_send_msg_to_pf(nic, &mbx); in __nicvf_set_rx_mode_task()
2022 struct nicvf *nic = container_of(vf_work, struct nicvf, rx_mode_work); in nicvf_set_rx_mode_task() local
2029 spin_lock_bh(&nic->rx_mode_wq_lock); in nicvf_set_rx_mode_task()
2033 spin_unlock_bh(&nic->rx_mode_wq_lock); in nicvf_set_rx_mode_task()
2035 __nicvf_set_rx_mode_task(mode, mc, nic); in nicvf_set_rx_mode_task()
2040 struct nicvf *nic = netdev_priv(netdev); in nicvf_set_rx_mode() local
2071 spin_lock(&nic->rx_mode_wq_lock); in nicvf_set_rx_mode()
2072 kfree(nic->rx_mode_work.mc); in nicvf_set_rx_mode()
2073 nic->rx_mode_work.mc = mc_list; in nicvf_set_rx_mode()
2074 nic->rx_mode_work.mode = mode; in nicvf_set_rx_mode()
2075 queue_work(nic->nicvf_rx_mode_wq, &nic->rx_mode_work.work); in nicvf_set_rx_mode()
2076 spin_unlock(&nic->rx_mode_wq_lock); in nicvf_set_rx_mode()
2098 struct nicvf *nic; in nicvf_probe() local
2147 nic = netdev_priv(netdev); in nicvf_probe()
2148 nic->netdev = netdev; in nicvf_probe()
2149 nic->pdev = pdev; in nicvf_probe()
2150 nic->pnicvf = nic; in nicvf_probe()
2151 nic->max_queues = qcount; in nicvf_probe()
2155 if (!nic->t88) in nicvf_probe()
2156 nic->max_queues *= 2; in nicvf_probe()
2157 nic->ptp_clock = ptp_clock; in nicvf_probe()
2160 mutex_init(&nic->rx_mode_mtx); in nicvf_probe()
2163 nic->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0); in nicvf_probe()
2164 if (!nic->reg_base) { in nicvf_probe()
2170 nic->drv_stats = netdev_alloc_pcpu_stats(struct nicvf_drv_stats); in nicvf_probe()
2171 if (!nic->drv_stats) { in nicvf_probe()
2176 err = nicvf_set_qset_resources(nic); in nicvf_probe()
2181 err = nicvf_register_misc_interrupt(nic); in nicvf_probe()
2185 nicvf_send_vf_struct(nic); in nicvf_probe()
2187 if (!pass1_silicon(nic->pdev)) in nicvf_probe()
2188 nic->hw_tso = true; in nicvf_probe()
2191 nic->iommu_domain = iommu_get_domain_for_dev(dev); in nicvf_probe()
2193 pci_read_config_word(nic->pdev, PCI_SUBSYSTEM_ID, &sdevid); in nicvf_probe()
2195 nic->t88 = true; in nicvf_probe()
2198 if (nic->sqs_mode) in nicvf_probe()
2201 err = nicvf_set_real_num_queues(netdev, nic->tx_queues, nic->rx_queues); in nicvf_probe()
2221 if (!pass1_silicon(nic->pdev) && in nicvf_probe()
2222 nic->rx_queues + nic->tx_queues <= nic->max_queues) in nicvf_probe()
2229 INIT_WORK(&nic->reset_task, nicvf_reset_task); in nicvf_probe()
2231 nic->nicvf_rx_mode_wq = alloc_ordered_workqueue("nicvf_rx_mode_wq_VF%d", in nicvf_probe()
2233 nic->vf_id); in nicvf_probe()
2234 if (!nic->nicvf_rx_mode_wq) { in nicvf_probe()
2240 INIT_WORK(&nic->rx_mode_work.work, nicvf_set_rx_mode_task); in nicvf_probe()
2241 spin_lock_init(&nic->rx_mode_wq_lock); in nicvf_probe()
2249 nic->msg_enable = debug; in nicvf_probe()
2256 destroy_workqueue(nic->nicvf_rx_mode_wq); in nicvf_probe()
2258 nicvf_unregister_interrupts(nic); in nicvf_probe()
2261 if (nic->drv_stats) in nicvf_probe()
2262 free_percpu(nic->drv_stats); in nicvf_probe()
2274 struct nicvf *nic; in nicvf_remove() local
2280 nic = netdev_priv(netdev); in nicvf_remove()
2281 pnetdev = nic->pnicvf->netdev; in nicvf_remove()
2288 if (nic->nicvf_rx_mode_wq) { in nicvf_remove()
2289 destroy_workqueue(nic->nicvf_rx_mode_wq); in nicvf_remove()
2290 nic->nicvf_rx_mode_wq = NULL; in nicvf_remove()
2292 nicvf_unregister_interrupts(nic); in nicvf_remove()
2294 if (nic->drv_stats) in nicvf_remove()
2295 free_percpu(nic->drv_stats); in nicvf_remove()
2296 cavium_ptp_put(nic->ptp_clock); in nicvf_remove()