1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2 * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
5 #include <rte_malloc.h>
6 #include <rte_ethdev_driver.h>
9 #include "ionic_logs.h"
10 #include "ionic_lif.h"
11 #include "ionic_ethdev.h"
12 #include "ionic_rx_filter.h"
13 #include "ionic_rxtx.h"
15 static int ionic_lif_addr_add(struct ionic_lif *lif, const uint8_t *addr);
16 static int ionic_lif_addr_del(struct ionic_lif *lif, const uint8_t *addr);
19 ionic_qcq_enable(struct ionic_qcq *qcq)
21 struct ionic_queue *q = &qcq->q;
22 struct ionic_lif *lif = q->lif;
23 struct ionic_dev *idev = &lif->adapter->idev;
24 struct ionic_admin_ctx ctx = {
27 .opcode = IONIC_CMD_Q_CONTROL,
28 .lif_index = lif->index,
31 .oper = IONIC_Q_ENABLE,
35 if (qcq->flags & IONIC_QCQ_F_INTR) {
36 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
37 IONIC_INTR_MASK_CLEAR);
40 return ionic_adminq_post_wait(lif, &ctx);
44 ionic_qcq_disable(struct ionic_qcq *qcq)
46 struct ionic_queue *q = &qcq->q;
47 struct ionic_lif *lif = q->lif;
48 struct ionic_dev *idev = &lif->adapter->idev;
49 struct ionic_admin_ctx ctx = {
52 .opcode = IONIC_CMD_Q_CONTROL,
53 .lif_index = lif->index,
56 .oper = IONIC_Q_DISABLE,
60 if (qcq->flags & IONIC_QCQ_F_INTR) {
61 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
65 return ionic_adminq_post_wait(lif, &ctx);
69 ionic_lif_stop(struct ionic_lif *lif __rte_unused)
71 /* Carrier OFF here */
77 ionic_lif_reset(struct ionic_lif *lif)
79 struct ionic_dev *idev = &lif->adapter->idev;
83 ionic_dev_cmd_lif_reset(idev, lif->index);
84 ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
88 ionic_lif_get_abs_stats(const struct ionic_lif *lif, struct rte_eth_stats *stats)
90 struct ionic_lif_stats *ls = &lif->info->stats;
92 uint32_t num_rx_q_counters = RTE_MIN(lif->nrxqcqs, (uint32_t)
93 RTE_ETHDEV_QUEUE_STAT_CNTRS);
94 uint32_t num_tx_q_counters = RTE_MIN(lif->ntxqcqs, (uint32_t)
95 RTE_ETHDEV_QUEUE_STAT_CNTRS);
97 memset(stats, 0, sizeof(*stats));
100 IONIC_PRINT(DEBUG, "Stats on port %u not yet initialized",
107 stats->ipackets = ls->rx_ucast_packets +
108 ls->rx_mcast_packets +
109 ls->rx_bcast_packets;
111 stats->ibytes = ls->rx_ucast_bytes +
115 for (i = 0; i < lif->nrxqcqs; i++) {
116 struct ionic_rx_stats *rx_stats = &lif->rxqcqs[i]->stats.rx;
118 rx_stats->no_cb_arg +
119 rx_stats->bad_cq_status +
125 ls->rx_ucast_drop_packets +
126 ls->rx_mcast_drop_packets +
127 ls->rx_bcast_drop_packets;
132 ls->rx_queue_disabled +
133 ls->rx_desc_fetch_error +
134 ls->rx_desc_data_error;
136 for (i = 0; i < num_rx_q_counters; i++) {
137 struct ionic_rx_stats *rx_stats = &lif->rxqcqs[i]->stats.rx;
138 stats->q_ipackets[i] = rx_stats->packets;
139 stats->q_ibytes[i] = rx_stats->bytes;
141 rx_stats->no_cb_arg +
142 rx_stats->bad_cq_status +
149 stats->opackets = ls->tx_ucast_packets +
150 ls->tx_mcast_packets +
151 ls->tx_bcast_packets;
153 stats->obytes = ls->tx_ucast_bytes +
157 for (i = 0; i < lif->ntxqcqs; i++) {
158 struct ionic_tx_stats *tx_stats = &lif->txqcqs[i]->stats.tx;
159 stats->oerrors += tx_stats->drop;
163 ls->tx_ucast_drop_packets +
164 ls->tx_mcast_drop_packets +
165 ls->tx_bcast_drop_packets;
169 ls->tx_queue_disabled +
170 ls->tx_desc_fetch_error +
171 ls->tx_desc_data_error;
173 for (i = 0; i < num_tx_q_counters; i++) {
174 struct ionic_tx_stats *tx_stats = &lif->txqcqs[i]->stats.tx;
175 stats->q_opackets[i] = tx_stats->packets;
176 stats->q_obytes[i] = tx_stats->bytes;
181 ionic_lif_get_stats(const struct ionic_lif *lif,
182 struct rte_eth_stats *stats)
184 ionic_lif_get_abs_stats(lif, stats);
186 stats->ipackets -= lif->stats_base.ipackets;
187 stats->opackets -= lif->stats_base.opackets;
188 stats->ibytes -= lif->stats_base.ibytes;
189 stats->obytes -= lif->stats_base.obytes;
190 stats->imissed -= lif->stats_base.imissed;
191 stats->ierrors -= lif->stats_base.ierrors;
192 stats->oerrors -= lif->stats_base.oerrors;
193 stats->rx_nombuf -= lif->stats_base.rx_nombuf;
197 ionic_lif_reset_stats(struct ionic_lif *lif)
201 for (i = 0; i < lif->nrxqcqs; i++) {
202 memset(&lif->rxqcqs[i]->stats.rx, 0,
203 sizeof(struct ionic_rx_stats));
204 memset(&lif->txqcqs[i]->stats.tx, 0,
205 sizeof(struct ionic_tx_stats));
208 ionic_lif_get_abs_stats(lif, &lif->stats_base);
212 ionic_lif_get_hw_stats(struct ionic_lif *lif, struct ionic_lif_stats *stats)
214 uint16_t i, count = sizeof(struct ionic_lif_stats) / sizeof(uint64_t);
215 uint64_t *stats64 = (uint64_t *)stats;
216 uint64_t *lif_stats64 = (uint64_t *)&lif->info->stats;
217 uint64_t *lif_stats64_base = (uint64_t *)&lif->lif_stats_base;
219 for (i = 0; i < count; i++)
220 stats64[i] = lif_stats64[i] - lif_stats64_base[i];
224 ionic_lif_reset_hw_stats(struct ionic_lif *lif)
226 uint16_t i, count = sizeof(struct ionic_lif_stats) / sizeof(uint64_t);
227 uint64_t *lif_stats64 = (uint64_t *)&lif->info->stats;
228 uint64_t *lif_stats64_base = (uint64_t *)&lif->lif_stats_base;
230 for (i = 0; i < count; i++)
231 lif_stats64_base[i] = lif_stats64[i];
235 ionic_lif_addr_add(struct ionic_lif *lif, const uint8_t *addr)
237 struct ionic_admin_ctx ctx = {
238 .pending_work = true,
239 .cmd.rx_filter_add = {
240 .opcode = IONIC_CMD_RX_FILTER_ADD,
241 .match = IONIC_RX_FILTER_MATCH_MAC,
246 memcpy(ctx.cmd.rx_filter_add.mac.addr, addr, RTE_ETHER_ADDR_LEN);
248 err = ionic_adminq_post_wait(lif, &ctx);
252 IONIC_PRINT(INFO, "rx_filter add (id %d)",
253 ctx.comp.rx_filter_add.filter_id);
255 return ionic_rx_filter_save(lif, 0, IONIC_RXQ_INDEX_ANY, &ctx);
259 ionic_lif_addr_del(struct ionic_lif *lif, const uint8_t *addr)
261 struct ionic_admin_ctx ctx = {
262 .pending_work = true,
263 .cmd.rx_filter_del = {
264 .opcode = IONIC_CMD_RX_FILTER_DEL,
267 struct ionic_rx_filter *f;
272 rte_spinlock_lock(&lif->rx_filters.lock);
274 f = ionic_rx_filter_by_addr(lif, addr);
276 rte_spinlock_unlock(&lif->rx_filters.lock);
280 ctx.cmd.rx_filter_del.filter_id = f->filter_id;
281 ionic_rx_filter_free(f);
283 rte_spinlock_unlock(&lif->rx_filters.lock);
285 err = ionic_adminq_post_wait(lif, &ctx);
289 IONIC_PRINT(INFO, "rx_filter del (id %d)",
290 ctx.cmd.rx_filter_del.filter_id);
296 ionic_dev_add_mac(struct rte_eth_dev *eth_dev,
297 struct rte_ether_addr *mac_addr,
298 uint32_t index __rte_unused, uint32_t pool __rte_unused)
300 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
304 return ionic_lif_addr_add(lif, (const uint8_t *)mac_addr);
308 ionic_dev_remove_mac(struct rte_eth_dev *eth_dev, uint32_t index __rte_unused)
310 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
311 struct ionic_adapter *adapter = lif->adapter;
315 if (index >= adapter->max_mac_addrs) {
317 "Index %u is above MAC filter limit %u",
318 index, adapter->max_mac_addrs);
322 if (!rte_is_valid_assigned_ether_addr(ð_dev->data->mac_addrs[index]))
325 ionic_lif_addr_del(lif, (const uint8_t *)
326 ð_dev->data->mac_addrs[index]);
330 ionic_dev_set_mac(struct rte_eth_dev *eth_dev, struct rte_ether_addr *mac_addr)
332 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
336 if (mac_addr == NULL) {
337 IONIC_PRINT(NOTICE, "New mac is null");
341 if (!rte_is_zero_ether_addr((struct rte_ether_addr *)lif->mac_addr)) {
342 IONIC_PRINT(INFO, "Deleting mac addr %pM",
344 ionic_lif_addr_del(lif, lif->mac_addr);
345 memset(lif->mac_addr, 0, RTE_ETHER_ADDR_LEN);
348 IONIC_PRINT(INFO, "Updating mac addr");
350 rte_ether_addr_copy(mac_addr, (struct rte_ether_addr *)lif->mac_addr);
352 return ionic_lif_addr_add(lif, (const uint8_t *)mac_addr);
356 ionic_vlan_rx_add_vid(struct ionic_lif *lif, uint16_t vid)
358 struct ionic_admin_ctx ctx = {
359 .pending_work = true,
360 .cmd.rx_filter_add = {
361 .opcode = IONIC_CMD_RX_FILTER_ADD,
362 .match = IONIC_RX_FILTER_MATCH_VLAN,
368 err = ionic_adminq_post_wait(lif, &ctx);
372 IONIC_PRINT(INFO, "rx_filter add VLAN %d (id %d)", vid,
373 ctx.comp.rx_filter_add.filter_id);
375 return ionic_rx_filter_save(lif, 0, IONIC_RXQ_INDEX_ANY, &ctx);
379 ionic_vlan_rx_kill_vid(struct ionic_lif *lif, uint16_t vid)
381 struct ionic_admin_ctx ctx = {
382 .pending_work = true,
383 .cmd.rx_filter_del = {
384 .opcode = IONIC_CMD_RX_FILTER_DEL,
387 struct ionic_rx_filter *f;
392 rte_spinlock_lock(&lif->rx_filters.lock);
394 f = ionic_rx_filter_by_vlan(lif, vid);
396 rte_spinlock_unlock(&lif->rx_filters.lock);
400 ctx.cmd.rx_filter_del.filter_id = f->filter_id;
401 ionic_rx_filter_free(f);
402 rte_spinlock_unlock(&lif->rx_filters.lock);
404 err = ionic_adminq_post_wait(lif, &ctx);
408 IONIC_PRINT(INFO, "rx_filter del VLAN %d (id %d)", vid,
409 ctx.cmd.rx_filter_del.filter_id);
415 ionic_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id,
418 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
422 err = ionic_vlan_rx_add_vid(lif, vlan_id);
424 err = ionic_vlan_rx_kill_vid(lif, vlan_id);
430 ionic_lif_rx_mode(struct ionic_lif *lif, uint32_t rx_mode)
432 struct ionic_admin_ctx ctx = {
433 .pending_work = true,
435 .opcode = IONIC_CMD_RX_MODE_SET,
436 .lif_index = lif->index,
442 if (rx_mode & IONIC_RX_MODE_F_UNICAST)
443 IONIC_PRINT(DEBUG, "rx_mode IONIC_RX_MODE_F_UNICAST");
444 if (rx_mode & IONIC_RX_MODE_F_MULTICAST)
445 IONIC_PRINT(DEBUG, "rx_mode IONIC_RX_MODE_F_MULTICAST");
446 if (rx_mode & IONIC_RX_MODE_F_BROADCAST)
447 IONIC_PRINT(DEBUG, "rx_mode IONIC_RX_MODE_F_BROADCAST");
448 if (rx_mode & IONIC_RX_MODE_F_PROMISC)
449 IONIC_PRINT(DEBUG, "rx_mode IONIC_RX_MODE_F_PROMISC");
450 if (rx_mode & IONIC_RX_MODE_F_ALLMULTI)
451 IONIC_PRINT(DEBUG, "rx_mode IONIC_RX_MODE_F_ALLMULTI");
453 err = ionic_adminq_post_wait(lif, &ctx);
455 IONIC_PRINT(ERR, "Failure setting RX mode");
459 ionic_set_rx_mode(struct ionic_lif *lif, uint32_t rx_mode)
461 if (lif->rx_mode != rx_mode) {
462 lif->rx_mode = rx_mode;
463 ionic_lif_rx_mode(lif, rx_mode);
468 ionic_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
470 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
471 uint32_t rx_mode = lif->rx_mode;
475 rx_mode |= IONIC_RX_MODE_F_PROMISC;
477 ionic_set_rx_mode(lif, rx_mode);
483 ionic_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
485 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
486 uint32_t rx_mode = lif->rx_mode;
488 rx_mode &= ~IONIC_RX_MODE_F_PROMISC;
490 ionic_set_rx_mode(lif, rx_mode);
496 ionic_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
498 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
499 uint32_t rx_mode = lif->rx_mode;
501 rx_mode |= IONIC_RX_MODE_F_ALLMULTI;
503 ionic_set_rx_mode(lif, rx_mode);
509 ionic_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
511 struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
512 uint32_t rx_mode = lif->rx_mode;
514 rx_mode &= ~IONIC_RX_MODE_F_ALLMULTI;
516 ionic_set_rx_mode(lif, rx_mode);
522 ionic_lif_change_mtu(struct ionic_lif *lif, int new_mtu)
524 struct ionic_admin_ctx ctx = {
525 .pending_work = true,
527 .opcode = IONIC_CMD_LIF_SETATTR,
529 .attr = IONIC_LIF_ATTR_MTU,
535 err = ionic_adminq_post_wait(lif, &ctx);
545 ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr)
547 struct ionic_adapter *adapter = lif->adapter;
548 struct ionic_dev *idev = &adapter->idev;
552 * Note: interrupt handler is called for index = 0 only
553 * (we use interrupts for the notifyq only anyway,
554 * which hash index = 0)
557 for (index = 0; index < adapter->nintrs; index++)
558 if (!adapter->intrs[index])
561 if (index == adapter->nintrs)
564 adapter->intrs[index] = true;
566 ionic_intr_init(idev, intr, index);
572 ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr)
574 if (intr->index != IONIC_INTR_INDEX_NOT_ASSIGNED)
575 lif->adapter->intrs[intr->index] = false;
579 ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
581 const char *base, uint32_t flags,
584 uint32_t cq_desc_size,
585 uint32_t sg_desc_size,
586 uint32_t pid, struct ionic_qcq **qcq)
588 struct ionic_dev *idev = &lif->adapter->idev;
589 struct ionic_qcq *new;
590 uint32_t q_size, cq_size, sg_size, total_size;
591 void *q_base, *cq_base, *sg_base;
592 rte_iova_t q_base_pa = 0;
593 rte_iova_t cq_base_pa = 0;
594 rte_iova_t sg_base_pa = 0;
595 uint32_t socket_id = rte_socket_id();
600 q_size = num_descs * desc_size;
601 cq_size = num_descs * cq_desc_size;
602 sg_size = num_descs * sg_desc_size;
604 total_size = RTE_ALIGN(q_size, PAGE_SIZE) +
605 RTE_ALIGN(cq_size, PAGE_SIZE);
607 * Note: aligning q_size/cq_size is not enough due to cq_base address
608 * aligning as q_base could be not aligned to the page.
611 total_size += PAGE_SIZE;
613 if (flags & IONIC_QCQ_F_SG) {
614 total_size += RTE_ALIGN(sg_size, PAGE_SIZE);
615 total_size += PAGE_SIZE;
618 new = rte_zmalloc("ionic", sizeof(*new), 0);
620 IONIC_PRINT(ERR, "Cannot allocate queue structure");
627 new->q.info = rte_zmalloc("ionic", sizeof(*new->q.info) * num_descs, 0);
629 IONIC_PRINT(ERR, "Cannot allocate queue info");
635 err = ionic_q_init(lif, idev, &new->q, index, num_descs,
636 desc_size, sg_desc_size, pid);
638 IONIC_PRINT(ERR, "Queue initialization failed");
642 if (flags & IONIC_QCQ_F_INTR) {
643 err = ionic_intr_alloc(lif, &new->intr);
647 ionic_intr_mask_assert(idev->intr_ctrl, new->intr.index,
648 IONIC_INTR_MASK_SET);
650 new->intr.index = IONIC_INTR_INDEX_NOT_ASSIGNED;
653 err = ionic_cq_init(lif, &new->cq, &new->intr,
654 num_descs, cq_desc_size);
656 IONIC_PRINT(ERR, "Completion queue initialization failed");
657 goto err_out_free_intr;
660 new->base_z = rte_eth_dma_zone_reserve(lif->eth_dev,
661 base /* name */, index /* queue_idx */,
662 total_size, IONIC_ALIGN, socket_id);
665 IONIC_PRINT(ERR, "Cannot reserve queue DMA memory");
667 goto err_out_free_intr;
670 new->base = new->base_z->addr;
671 new->base_pa = new->base_z->iova;
672 new->total_size = total_size;
675 q_base_pa = new->base_pa;
677 cq_base = (void *)RTE_ALIGN((uintptr_t)q_base + q_size, PAGE_SIZE);
678 cq_base_pa = RTE_ALIGN(q_base_pa + q_size, PAGE_SIZE);
680 if (flags & IONIC_QCQ_F_SG) {
681 sg_base = (void *)RTE_ALIGN((uintptr_t)cq_base + cq_size,
683 sg_base_pa = RTE_ALIGN(cq_base_pa + cq_size, PAGE_SIZE);
684 ionic_q_sg_map(&new->q, sg_base, sg_base_pa);
687 IONIC_PRINT(DEBUG, "Q-Base-PA = %ju CQ-Base-PA = %ju "
689 q_base_pa, cq_base_pa, sg_base_pa);
691 ionic_q_map(&new->q, q_base, q_base_pa);
692 ionic_cq_map(&new->cq, cq_base, cq_base_pa);
693 ionic_cq_bind(&new->cq, &new->q);
700 if (flags & IONIC_QCQ_F_INTR)
701 ionic_intr_free(lif, &new->intr);
707 ionic_qcq_free(struct ionic_qcq *qcq)
712 rte_memzone_free(qcq->base_z);
717 rte_free(qcq->q.info);
725 ionic_rx_qcq_alloc(struct ionic_lif *lif, uint32_t index, uint16_t nrxq_descs,
726 struct ionic_qcq **qcq)
731 flags = IONIC_QCQ_F_SG;
732 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, index, "rx", flags,
734 sizeof(struct ionic_rxq_desc),
735 sizeof(struct ionic_rxq_comp),
736 sizeof(struct ionic_rxq_sg_desc),
737 lif->kern_pid, &lif->rxqcqs[index]);
741 *qcq = lif->rxqcqs[index];
747 ionic_tx_qcq_alloc(struct ionic_lif *lif, uint32_t index, uint16_t ntxq_descs,
748 struct ionic_qcq **qcq)
753 flags = IONIC_QCQ_F_SG;
754 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, index, "tx", flags,
756 sizeof(struct ionic_txq_desc),
757 sizeof(struct ionic_txq_comp),
758 sizeof(struct ionic_txq_sg_desc),
759 lif->kern_pid, &lif->txqcqs[index]);
763 *qcq = lif->txqcqs[index];
769 ionic_admin_qcq_alloc(struct ionic_lif *lif)
775 err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags,
777 sizeof(struct ionic_admin_cmd),
778 sizeof(struct ionic_admin_comp),
780 lif->kern_pid, &lif->adminqcq);
788 ionic_notify_qcq_alloc(struct ionic_lif *lif)
793 flags = IONIC_QCQ_F_NOTIFYQ | IONIC_QCQ_F_INTR;
795 err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notify",
797 IONIC_NOTIFYQ_LENGTH,
798 sizeof(struct ionic_notifyq_cmd),
799 sizeof(union ionic_notifyq_comp),
801 lif->kern_pid, &lif->notifyqcq);
809 ionic_bus_map_dbpage(struct ionic_adapter *adapter, int page_num)
811 char *vaddr = adapter->bars[IONIC_PCI_BAR_DBELL].vaddr;
813 if (adapter->num_bars <= IONIC_PCI_BAR_DBELL)
816 return (void *)&vaddr[page_num << PAGE_SHIFT];
820 ionic_lif_alloc(struct ionic_lif *lif)
822 struct ionic_adapter *adapter = lif->adapter;
823 uint32_t socket_id = rte_socket_id();
827 snprintf(lif->name, sizeof(lif->name), "lif%u", lif->index);
829 IONIC_PRINT(DEBUG, "Allocating Lif Info");
831 rte_spinlock_init(&lif->adminq_lock);
832 rte_spinlock_init(&lif->adminq_service_lock);
836 dbpage_num = ionic_db_page_num(lif, 0);
838 lif->kern_dbpage = ionic_bus_map_dbpage(adapter, dbpage_num);
839 if (!lif->kern_dbpage) {
840 IONIC_PRINT(ERR, "Cannot map dbpage, aborting");
844 lif->txqcqs = rte_zmalloc("ionic", sizeof(*lif->txqcqs) *
845 adapter->max_ntxqs_per_lif, 0);
848 IONIC_PRINT(ERR, "Cannot allocate tx queues array");
852 lif->rxqcqs = rte_zmalloc("ionic", sizeof(*lif->rxqcqs) *
853 adapter->max_nrxqs_per_lif, 0);
856 IONIC_PRINT(ERR, "Cannot allocate rx queues array");
860 IONIC_PRINT(DEBUG, "Allocating Notify Queue");
862 err = ionic_notify_qcq_alloc(lif);
864 IONIC_PRINT(ERR, "Cannot allocate notify queue");
868 IONIC_PRINT(DEBUG, "Allocating Admin Queue");
870 IONIC_PRINT(DEBUG, "Allocating Admin Queue");
872 err = ionic_admin_qcq_alloc(lif);
874 IONIC_PRINT(ERR, "Cannot allocate admin queue");
878 IONIC_PRINT(DEBUG, "Allocating Lif Info");
880 lif->info_sz = RTE_ALIGN(sizeof(*lif->info), PAGE_SIZE);
882 lif->info_z = rte_eth_dma_zone_reserve(lif->eth_dev,
883 "lif_info", 0 /* queue_idx*/,
884 lif->info_sz, IONIC_ALIGN, socket_id);
886 IONIC_PRINT(ERR, "Cannot allocate lif info memory");
890 lif->info = lif->info_z->addr;
891 lif->info_pa = lif->info_z->iova;
897 ionic_lif_free(struct ionic_lif *lif)
899 if (lif->notifyqcq) {
900 ionic_qcq_free(lif->notifyqcq);
901 lif->notifyqcq = NULL;
905 ionic_qcq_free(lif->adminqcq);
906 lif->adminqcq = NULL;
910 rte_free(lif->txqcqs);
915 rte_free(lif->rxqcqs);
920 rte_memzone_free(lif->info_z);
926 ionic_lif_rss_config(struct ionic_lif *lif,
927 const uint16_t types, const uint8_t *key, const uint32_t *indir)
929 struct ionic_admin_ctx ctx = {
930 .pending_work = true,
932 .opcode = IONIC_CMD_LIF_SETATTR,
933 .attr = IONIC_LIF_ATTR_RSS,
935 .rss.addr = lif->rss_ind_tbl_pa,
942 lif->rss_types = types;
945 memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE);
948 for (i = 0; i < lif->adapter->ident.lif.eth.rss_ind_tbl_sz; i++)
949 lif->rss_ind_tbl[i] = indir[i];
951 memcpy(ctx.cmd.lif_setattr.rss.key, lif->rss_hash_key,
952 IONIC_RSS_HASH_KEY_SIZE);
954 return ionic_adminq_post_wait(lif, &ctx);
958 ionic_lif_rss_setup(struct ionic_lif *lif)
960 size_t tbl_size = sizeof(*lif->rss_ind_tbl) *
961 lif->adapter->ident.lif.eth.rss_ind_tbl_sz;
962 static const uint8_t toeplitz_symmetric_key[] = {
963 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
964 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
965 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
966 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
967 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
969 uint32_t socket_id = rte_socket_id();
975 lif->rss_ind_tbl_z = rte_eth_dma_zone_reserve(lif->eth_dev,
977 0 /* queue_idx*/, tbl_size, IONIC_ALIGN, socket_id);
979 if (!lif->rss_ind_tbl_z) {
980 IONIC_PRINT(ERR, "OOM");
984 lif->rss_ind_tbl = lif->rss_ind_tbl_z->addr;
985 lif->rss_ind_tbl_pa = lif->rss_ind_tbl_z->iova;
987 /* Fill indirection table with 'default' values */
988 for (i = 0; i < lif->adapter->ident.lif.eth.rss_ind_tbl_sz; i++)
989 lif->rss_ind_tbl[i] = i % lif->nrxqcqs;
991 err = ionic_lif_rss_config(lif, IONIC_RSS_OFFLOAD_ALL,
992 toeplitz_symmetric_key, NULL);
1000 ionic_lif_rss_teardown(struct ionic_lif *lif)
1002 if (!lif->rss_ind_tbl)
1005 if (lif->rss_ind_tbl_z) {
1006 /* Disable RSS on the NIC */
1007 ionic_lif_rss_config(lif, 0x0, NULL, NULL);
1009 lif->rss_ind_tbl = NULL;
1010 lif->rss_ind_tbl_pa = 0;
1011 rte_memzone_free(lif->rss_ind_tbl_z);
1012 lif->rss_ind_tbl_z = NULL;
1017 ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq)
1019 struct ionic_dev *idev = &lif->adapter->idev;
1021 if (!(qcq->flags & IONIC_QCQ_F_INITED))
1024 if (qcq->flags & IONIC_QCQ_F_INTR)
1025 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
1026 IONIC_INTR_MASK_SET);
1028 qcq->flags &= ~IONIC_QCQ_F_INITED;
1032 ionic_lif_txq_deinit(struct ionic_qcq *qcq)
1034 ionic_lif_qcq_deinit(qcq->lif, qcq);
1038 ionic_lif_rxq_deinit(struct ionic_qcq *qcq)
1040 ionic_lif_qcq_deinit(qcq->lif, qcq);
1044 ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
1045 void *cb_arg __rte_unused)
1047 struct ionic_admin_comp *cq_desc_base = cq->base;
1048 struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
1050 if (!color_match(cq_desc->color, cq->done_color))
1053 ionic_q_service(cq->bound_q, cq_desc_index, cq_desc->comp_index, NULL);
1058 /* This acts like ionic_napi */
1060 ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
1063 struct ionic_cq *cq = &qcq->cq;
1066 work_done = ionic_cq_service(cq, budget, cb, cb_arg);
1072 ionic_link_status_check(struct ionic_lif *lif)
1074 struct ionic_adapter *adapter = lif->adapter;
1077 lif->state &= ~IONIC_LIF_F_LINK_CHECK_NEEDED;
1082 link_up = (lif->info->status.link_status == IONIC_PORT_OPER_STATUS_UP);
1084 if ((link_up && adapter->link_up) ||
1085 (!link_up && !adapter->link_up))
1089 IONIC_PRINT(DEBUG, "Link up - %d Gbps",
1090 lif->info->status.link_speed);
1091 adapter->link_speed = lif->info->status.link_speed;
1093 IONIC_PRINT(DEBUG, "Link down");
1096 adapter->link_up = link_up;
1100 ionic_notifyq_cb(struct ionic_cq *cq, uint32_t cq_desc_index, void *cb_arg)
1102 union ionic_notifyq_comp *cq_desc_base = cq->base;
1103 union ionic_notifyq_comp *cq_desc = &cq_desc_base[cq_desc_index];
1104 struct ionic_lif *lif = cb_arg;
1106 IONIC_PRINT(DEBUG, "Notifyq callback eid = %jd ecode = %d",
1107 cq_desc->event.eid, cq_desc->event.ecode);
1109 /* Have we run out of new completions to process? */
1110 if (!(cq_desc->event.eid > lif->last_eid))
1113 lif->last_eid = cq_desc->event.eid;
1115 switch (cq_desc->event.ecode) {
1116 case IONIC_EVENT_LINK_CHANGE:
1118 "Notifyq IONIC_EVENT_LINK_CHANGE eid=%jd link_status=%d link_speed=%d",
1120 cq_desc->link_change.link_status,
1121 cq_desc->link_change.link_speed);
1123 lif->state |= IONIC_LIF_F_LINK_CHECK_NEEDED;
1127 IONIC_PRINT(WARNING, "Notifyq bad event ecode=%d eid=%jd",
1128 cq_desc->event.ecode, cq_desc->event.eid);
1136 ionic_notifyq_handler(struct ionic_lif *lif, int budget)
1138 struct ionic_dev *idev = &lif->adapter->idev;
1139 struct ionic_qcq *qcq = lif->notifyqcq;
1142 if (!(qcq->flags & IONIC_QCQ_F_INITED)) {
1143 IONIC_PRINT(DEBUG, "Notifyq not yet initialized");
1147 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
1148 IONIC_INTR_MASK_SET);
1150 work_done = ionic_qcq_service(qcq, budget, ionic_notifyq_cb, lif);
1152 if (lif->state & IONIC_LIF_F_LINK_CHECK_NEEDED)
1153 ionic_link_status_check(lif);
1155 ionic_intr_credits(idev->intr_ctrl, qcq->intr.index,
1156 work_done, IONIC_INTR_CRED_RESET_COALESCE);
1158 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
1159 IONIC_INTR_MASK_CLEAR);
1165 ionic_lif_adminq_init(struct ionic_lif *lif)
1167 struct ionic_dev *idev = &lif->adapter->idev;
1168 struct ionic_qcq *qcq = lif->adminqcq;
1169 struct ionic_queue *q = &qcq->q;
1170 struct ionic_q_init_comp comp;
1173 ionic_dev_cmd_adminq_init(idev, qcq, lif->index, qcq->intr.index);
1174 err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
1178 ionic_dev_cmd_comp(idev, &comp);
1180 q->hw_type = comp.hw_type;
1181 q->hw_index = comp.hw_index;
1182 q->db = ionic_db_map(lif, q);
1184 IONIC_PRINT(DEBUG, "adminq->hw_type %d", q->hw_type);
1185 IONIC_PRINT(DEBUG, "adminq->hw_index %d", q->hw_index);
1186 IONIC_PRINT(DEBUG, "adminq->db %p", q->db);
1188 if (qcq->flags & IONIC_QCQ_F_INTR)
1189 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
1190 IONIC_INTR_MASK_CLEAR);
1192 qcq->flags |= IONIC_QCQ_F_INITED;
1198 ionic_lif_notifyq_init(struct ionic_lif *lif)
1200 struct ionic_dev *idev = &lif->adapter->idev;
1201 struct ionic_qcq *qcq = lif->notifyqcq;
1202 struct ionic_queue *q = &qcq->q;
1205 struct ionic_admin_ctx ctx = {
1206 .pending_work = true,
1208 .opcode = IONIC_CMD_Q_INIT,
1209 .lif_index = lif->index,
1212 .flags = (IONIC_QINIT_F_IRQ | IONIC_QINIT_F_ENA),
1213 .intr_index = qcq->intr.index,
1215 .ring_size = rte_log2_u32(q->num_descs),
1216 .ring_base = q->base_pa,
1220 IONIC_PRINT(DEBUG, "notifyq_init.pid %d", ctx.cmd.q_init.pid);
1221 IONIC_PRINT(DEBUG, "notifyq_init.index %d",
1222 ctx.cmd.q_init.index);
1223 IONIC_PRINT(DEBUG, "notifyq_init.ring_base 0x%" PRIx64 "",
1224 ctx.cmd.q_init.ring_base);
1225 IONIC_PRINT(DEBUG, "notifyq_init.ring_size %d",
1226 ctx.cmd.q_init.ring_size);
1228 err = ionic_adminq_post_wait(lif, &ctx);
1232 q->hw_type = ctx.comp.q_init.hw_type;
1233 q->hw_index = ctx.comp.q_init.hw_index;
1236 IONIC_PRINT(DEBUG, "notifyq->hw_type %d", q->hw_type);
1237 IONIC_PRINT(DEBUG, "notifyq->hw_index %d", q->hw_index);
1238 IONIC_PRINT(DEBUG, "notifyq->db %p", q->db);
1240 if (qcq->flags & IONIC_QCQ_F_INTR)
1241 ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
1242 IONIC_INTR_MASK_CLEAR);
1244 qcq->flags |= IONIC_QCQ_F_INITED;
1250 ionic_lif_set_features(struct ionic_lif *lif)
1252 struct ionic_admin_ctx ctx = {
1253 .pending_work = true,
1254 .cmd.lif_setattr = {
1255 .opcode = IONIC_CMD_LIF_SETATTR,
1256 .index = lif->index,
1257 .attr = IONIC_LIF_ATTR_FEATURES,
1258 .features = lif->features,
1263 err = ionic_adminq_post_wait(lif, &ctx);
1267 lif->hw_features = (ctx.cmd.lif_setattr.features &
1268 ctx.comp.lif_setattr.features);
1270 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG)
1271 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_VLAN_TX_TAG");
1272 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP)
1273 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_VLAN_RX_STRIP");
1274 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER)
1275 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_VLAN_RX_FILTER");
1276 if (lif->hw_features & IONIC_ETH_HW_RX_HASH)
1277 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_RX_HASH");
1278 if (lif->hw_features & IONIC_ETH_HW_TX_SG)
1279 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TX_SG");
1280 if (lif->hw_features & IONIC_ETH_HW_RX_SG)
1281 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_RX_SG");
1282 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM)
1283 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TX_CSUM");
1284 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM)
1285 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_RX_CSUM");
1286 if (lif->hw_features & IONIC_ETH_HW_TSO)
1287 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO");
1288 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6)
1289 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_IPV6");
1290 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN)
1291 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_ECN");
1292 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE)
1293 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_GRE");
1294 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM)
1295 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_GRE_CSUM");
1296 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4)
1297 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_IPXIP4");
1298 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6)
1299 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_IPXIP6");
1300 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP)
1301 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_UDP");
1302 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM)
1303 IONIC_PRINT(DEBUG, "feature IONIC_ETH_HW_TSO_UDP_CSUM");
1309 ionic_lif_txq_init(struct ionic_qcq *qcq)
1311 struct ionic_queue *q = &qcq->q;
1312 struct ionic_lif *lif = qcq->lif;
1313 struct ionic_cq *cq = &qcq->cq;
1314 struct ionic_admin_ctx ctx = {
1315 .pending_work = true,
1317 .opcode = IONIC_CMD_Q_INIT,
1318 .lif_index = lif->index,
1321 .flags = IONIC_QINIT_F_SG,
1322 .intr_index = cq->bound_intr->index,
1324 .ring_size = rte_log2_u32(q->num_descs),
1325 .ring_base = q->base_pa,
1326 .cq_ring_base = cq->base_pa,
1327 .sg_ring_base = q->sg_base_pa,
1332 IONIC_PRINT(DEBUG, "txq_init.pid %d", ctx.cmd.q_init.pid);
1333 IONIC_PRINT(DEBUG, "txq_init.index %d", ctx.cmd.q_init.index);
1334 IONIC_PRINT(DEBUG, "txq_init.ring_base 0x%" PRIx64 "",
1335 ctx.cmd.q_init.ring_base);
1336 IONIC_PRINT(DEBUG, "txq_init.ring_size %d",
1337 ctx.cmd.q_init.ring_size);
1339 err = ionic_adminq_post_wait(qcq->lif, &ctx);
1343 q->hw_type = ctx.comp.q_init.hw_type;
1344 q->hw_index = ctx.comp.q_init.hw_index;
1345 q->db = ionic_db_map(lif, q);
1347 IONIC_PRINT(DEBUG, "txq->hw_type %d", q->hw_type);
1348 IONIC_PRINT(DEBUG, "txq->hw_index %d", q->hw_index);
1349 IONIC_PRINT(DEBUG, "txq->db %p", q->db);
1351 qcq->flags |= IONIC_QCQ_F_INITED;
1357 ionic_lif_rxq_init(struct ionic_qcq *qcq)
1359 struct ionic_queue *q = &qcq->q;
1360 struct ionic_lif *lif = qcq->lif;
1361 struct ionic_cq *cq = &qcq->cq;
1362 struct ionic_admin_ctx ctx = {
1363 .pending_work = true,
1365 .opcode = IONIC_CMD_Q_INIT,
1366 .lif_index = lif->index,
1369 .flags = IONIC_QINIT_F_SG,
1370 .intr_index = cq->bound_intr->index,
1372 .ring_size = rte_log2_u32(q->num_descs),
1373 .ring_base = q->base_pa,
1374 .cq_ring_base = cq->base_pa,
1375 .sg_ring_base = q->sg_base_pa,
1380 IONIC_PRINT(DEBUG, "rxq_init.pid %d", ctx.cmd.q_init.pid);
1381 IONIC_PRINT(DEBUG, "rxq_init.index %d", ctx.cmd.q_init.index);
1382 IONIC_PRINT(DEBUG, "rxq_init.ring_base 0x%" PRIx64 "",
1383 ctx.cmd.q_init.ring_base);
1384 IONIC_PRINT(DEBUG, "rxq_init.ring_size %d",
1385 ctx.cmd.q_init.ring_size);
1387 err = ionic_adminq_post_wait(qcq->lif, &ctx);
1391 q->hw_type = ctx.comp.q_init.hw_type;
1392 q->hw_index = ctx.comp.q_init.hw_index;
1393 q->db = ionic_db_map(lif, q);
1395 qcq->flags |= IONIC_QCQ_F_INITED;
1397 IONIC_PRINT(DEBUG, "rxq->hw_type %d", q->hw_type);
1398 IONIC_PRINT(DEBUG, "rxq->hw_index %d", q->hw_index);
1399 IONIC_PRINT(DEBUG, "rxq->db %p", q->db);
1405 ionic_station_set(struct ionic_lif *lif)
1407 struct ionic_admin_ctx ctx = {
1408 .pending_work = true,
1409 .cmd.lif_getattr = {
1410 .opcode = IONIC_CMD_LIF_GETATTR,
1411 .index = lif->index,
1412 .attr = IONIC_LIF_ATTR_MAC,
1419 err = ionic_adminq_post_wait(lif, &ctx);
1423 if (!rte_is_zero_ether_addr((struct rte_ether_addr *)
1425 IONIC_PRINT(INFO, "deleting station MAC addr");
1427 ionic_lif_addr_del(lif, lif->mac_addr);
1430 memcpy(lif->mac_addr, ctx.comp.lif_getattr.mac, RTE_ETHER_ADDR_LEN);
1432 if (rte_is_zero_ether_addr((struct rte_ether_addr *)lif->mac_addr)) {
1433 IONIC_PRINT(NOTICE, "empty MAC addr (VF?)");
1437 IONIC_PRINT(DEBUG, "adding station MAC addr");
1439 ionic_lif_addr_add(lif, lif->mac_addr);
1445 ionic_lif_set_name(struct ionic_lif *lif)
1447 struct ionic_admin_ctx ctx = {
1448 .pending_work = true,
1449 .cmd.lif_setattr = {
1450 .opcode = IONIC_CMD_LIF_SETATTR,
1451 .index = lif->index,
1452 .attr = IONIC_LIF_ATTR_NAME,
1456 snprintf(ctx.cmd.lif_setattr.name, sizeof(ctx.cmd.lif_setattr.name),
1457 "%d", lif->port_id);
1459 ionic_adminq_post_wait(lif, &ctx);
1463 ionic_lif_init(struct ionic_lif *lif)
1465 struct ionic_dev *idev = &lif->adapter->idev;
1466 struct ionic_q_init_comp comp;
1469 memset(&lif->stats_base, 0, sizeof(lif->stats_base));
1471 ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa);
1472 err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
1473 ionic_dev_cmd_comp(idev, &comp);
1477 lif->hw_index = comp.hw_index;
1479 err = ionic_lif_adminq_init(lif);
1483 err = ionic_lif_notifyq_init(lif);
1485 goto err_out_adminq_deinit;
1488 IONIC_ETH_HW_VLAN_TX_TAG
1489 | IONIC_ETH_HW_VLAN_RX_STRIP
1490 | IONIC_ETH_HW_VLAN_RX_FILTER
1491 | IONIC_ETH_HW_RX_HASH
1492 | IONIC_ETH_HW_TX_SG
1493 | IONIC_ETH_HW_RX_SG
1494 | IONIC_ETH_HW_TX_CSUM
1495 | IONIC_ETH_HW_RX_CSUM
1497 | IONIC_ETH_HW_TSO_IPV6
1498 | IONIC_ETH_HW_TSO_ECN;
1500 err = ionic_lif_set_features(lif);
1502 goto err_out_notifyq_deinit;
1504 err = ionic_rx_filters_init(lif);
1506 goto err_out_notifyq_deinit;
1508 err = ionic_station_set(lif);
1510 goto err_out_rx_filter_deinit;
1512 ionic_lif_set_name(lif);
1514 lif->state |= IONIC_LIF_F_INITED;
1518 err_out_rx_filter_deinit:
1519 ionic_rx_filters_deinit(lif);
1521 err_out_notifyq_deinit:
1522 ionic_lif_qcq_deinit(lif, lif->notifyqcq);
1524 err_out_adminq_deinit:
1525 ionic_lif_qcq_deinit(lif, lif->adminqcq);
1531 ionic_lif_deinit(struct ionic_lif *lif)
1533 if (!(lif->state & IONIC_LIF_F_INITED))
1536 ionic_rx_filters_deinit(lif);
1537 ionic_lif_rss_teardown(lif);
1538 ionic_lif_qcq_deinit(lif, lif->notifyqcq);
1539 ionic_lif_qcq_deinit(lif, lif->adminqcq);
1541 lif->state &= ~IONIC_LIF_F_INITED;
1545 ionic_lif_configure(struct ionic_lif *lif)
1547 struct ionic_identity *ident = &lif->adapter->ident;
1548 uint32_t ntxqs_per_lif =
1549 ident->lif.eth.config.queue_count[IONIC_QTYPE_TXQ];
1550 uint32_t nrxqs_per_lif =
1551 ident->lif.eth.config.queue_count[IONIC_QTYPE_RXQ];
1552 uint32_t nrxqs = lif->eth_dev->data->nb_rx_queues;
1553 uint32_t ntxqs = lif->eth_dev->data->nb_tx_queues;
1555 lif->port_id = lif->eth_dev->data->port_id;
1557 IONIC_PRINT(DEBUG, "Configuring LIF on port %u",
1561 nrxqs_per_lif = RTE_MIN(nrxqs_per_lif, nrxqs);
1564 ntxqs_per_lif = RTE_MIN(ntxqs_per_lif, ntxqs);
1566 lif->nrxqcqs = nrxqs_per_lif;
1567 lif->ntxqcqs = ntxqs_per_lif;
1573 ionic_lif_start(struct ionic_lif *lif)
1575 uint32_t rx_mode = 0;
1579 IONIC_PRINT(DEBUG, "Setting RSS configuration on port %u",
1582 err = ionic_lif_rss_setup(lif);
1586 IONIC_PRINT(DEBUG, "Setting RX mode on port %u",
1589 rx_mode |= IONIC_RX_MODE_F_UNICAST;
1590 rx_mode |= IONIC_RX_MODE_F_MULTICAST;
1591 rx_mode |= IONIC_RX_MODE_F_BROADCAST;
1593 lif->rx_mode = 0; /* set by ionic_set_rx_mode */
1595 ionic_set_rx_mode(lif, rx_mode);
1597 IONIC_PRINT(DEBUG, "Starting %u RX queues and %u TX queues "
1599 lif->nrxqcqs, lif->ntxqcqs, lif->port_id);
1601 for (i = 0; i < lif->nrxqcqs; i++) {
1602 struct ionic_qcq *rxq = lif->rxqcqs[i];
1603 if (!rxq->deferred_start) {
1604 err = ionic_dev_rx_queue_start(lif->eth_dev, i);
1611 for (i = 0; i < lif->ntxqcqs; i++) {
1612 struct ionic_qcq *txq = lif->txqcqs[i];
1613 if (!txq->deferred_start) {
1614 err = ionic_dev_tx_queue_start(lif->eth_dev, i);
1621 ionic_link_status_check(lif);
1623 /* Carrier ON here */
1629 ionic_lif_identify(struct ionic_adapter *adapter)
1631 struct ionic_dev *idev = &adapter->idev;
1632 struct ionic_identity *ident = &adapter->ident;
1635 unsigned int lif_words = sizeof(ident->lif.words) /
1636 sizeof(ident->lif.words[0]);
1637 unsigned int cmd_words = sizeof(idev->dev_cmd->data) /
1638 sizeof(idev->dev_cmd->data[0]);
1639 unsigned int nwords;
1641 ionic_dev_cmd_lif_identify(idev, IONIC_LIF_TYPE_CLASSIC,
1642 IONIC_IDENTITY_VERSION_1);
1643 err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
1647 nwords = RTE_MIN(lif_words, cmd_words);
1648 for (i = 0; i < nwords; i++)
1649 ident->lif.words[i] = ioread32(&idev->dev_cmd->data[i]);
1651 IONIC_PRINT(INFO, "capabilities 0x%" PRIx64 " ",
1652 ident->lif.capabilities);
1654 IONIC_PRINT(INFO, "eth.max_ucast_filters 0x%" PRIx32 " ",
1655 ident->lif.eth.max_ucast_filters);
1656 IONIC_PRINT(INFO, "eth.max_mcast_filters 0x%" PRIx32 " ",
1657 ident->lif.eth.max_mcast_filters);
1659 IONIC_PRINT(INFO, "eth.features 0x%" PRIx64 " ",
1660 ident->lif.eth.config.features);
1661 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_ADMINQ] 0x%" PRIx32 " ",
1662 ident->lif.eth.config.queue_count[IONIC_QTYPE_ADMINQ]);
1663 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_NOTIFYQ] 0x%" PRIx32 " ",
1664 ident->lif.eth.config.queue_count[IONIC_QTYPE_NOTIFYQ]);
1665 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_RXQ] 0x%" PRIx32 " ",
1666 ident->lif.eth.config.queue_count[IONIC_QTYPE_RXQ]);
1667 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_TXQ] 0x%" PRIx32 " ",
1668 ident->lif.eth.config.queue_count[IONIC_QTYPE_TXQ]);
1674 ionic_lifs_size(struct ionic_adapter *adapter)
1676 struct ionic_identity *ident = &adapter->ident;
1677 uint32_t nlifs = ident->dev.nlifs;
1678 uint32_t nintrs, dev_nintrs = ident->dev.nintrs;
1680 adapter->max_ntxqs_per_lif =
1681 ident->lif.eth.config.queue_count[IONIC_QTYPE_TXQ];
1682 adapter->max_nrxqs_per_lif =
1683 ident->lif.eth.config.queue_count[IONIC_QTYPE_RXQ];
1685 nintrs = nlifs * 1 /* notifyq */;
1687 if (nintrs > dev_nintrs) {
1688 IONIC_PRINT(ERR, "At most %d intr queues supported, minimum required is %u",
1689 dev_nintrs, nintrs);
1693 adapter->nintrs = nintrs;