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"
14 ionic_lif_alloc(struct ionic_lif *lif)
16 uint32_t socket_id = rte_socket_id();
18 snprintf(lif->name, sizeof(lif->name), "lif%u", lif->index);
20 IONIC_PRINT(DEBUG, "Allocating Lif Info");
22 lif->info_sz = RTE_ALIGN(sizeof(*lif->info), PAGE_SIZE);
24 lif->info_z = rte_eth_dma_zone_reserve(lif->eth_dev,
25 "lif_info", 0 /* queue_idx*/,
26 lif->info_sz, IONIC_ALIGN, socket_id);
28 IONIC_PRINT(ERR, "Cannot allocate lif info memory");
32 lif->info = lif->info_z->addr;
33 lif->info_pa = lif->info_z->iova;
39 ionic_lif_free(struct ionic_lif *lif)
42 rte_memzone_free(lif->info_z);
48 ionic_lif_init(struct ionic_lif *lif)
50 struct ionic_dev *idev = &lif->adapter->idev;
51 struct ionic_q_init_comp comp;
54 ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa);
55 err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
56 ionic_dev_cmd_comp(idev, &comp);
60 lif->hw_index = comp.hw_index;
62 lif->state |= IONIC_LIF_F_INITED;
68 ionic_lif_deinit(struct ionic_lif *lif)
70 if (!(lif->state & IONIC_LIF_F_INITED))
73 lif->state &= ~IONIC_LIF_F_INITED;
77 ionic_lif_identify(struct ionic_adapter *adapter)
79 struct ionic_dev *idev = &adapter->idev;
80 struct ionic_identity *ident = &adapter->ident;
83 unsigned int lif_words = sizeof(ident->lif.words) /
84 sizeof(ident->lif.words[0]);
85 unsigned int cmd_words = sizeof(idev->dev_cmd->data) /
86 sizeof(idev->dev_cmd->data[0]);
89 ionic_dev_cmd_lif_identify(idev, IONIC_LIF_TYPE_CLASSIC,
90 IONIC_IDENTITY_VERSION_1);
91 err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
95 nwords = RTE_MIN(lif_words, cmd_words);
96 for (i = 0; i < nwords; i++)
97 ident->lif.words[i] = ioread32(&idev->dev_cmd->data[i]);
99 IONIC_PRINT(INFO, "capabilities 0x%" PRIx64 " ",
100 ident->lif.capabilities);
102 IONIC_PRINT(INFO, "eth.max_ucast_filters 0x%" PRIx32 " ",
103 ident->lif.eth.max_ucast_filters);
104 IONIC_PRINT(INFO, "eth.max_mcast_filters 0x%" PRIx32 " ",
105 ident->lif.eth.max_mcast_filters);
107 IONIC_PRINT(INFO, "eth.features 0x%" PRIx64 " ",
108 ident->lif.eth.config.features);
109 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_ADMINQ] 0x%" PRIx32 " ",
110 ident->lif.eth.config.queue_count[IONIC_QTYPE_ADMINQ]);
111 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_NOTIFYQ] 0x%" PRIx32 " ",
112 ident->lif.eth.config.queue_count[IONIC_QTYPE_NOTIFYQ]);
113 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_RXQ] 0x%" PRIx32 " ",
114 ident->lif.eth.config.queue_count[IONIC_QTYPE_RXQ]);
115 IONIC_PRINT(INFO, "eth.queue_count[IONIC_QTYPE_TXQ] 0x%" PRIx32 " ",
116 ident->lif.eth.config.queue_count[IONIC_QTYPE_TXQ]);
122 ionic_lifs_size(struct ionic_adapter *adapter)
124 struct ionic_identity *ident = &adapter->ident;
125 uint32_t nlifs = ident->dev.nlifs;
126 uint32_t nintrs, dev_nintrs = ident->dev.nintrs;
128 adapter->max_ntxqs_per_lif =
129 ident->lif.eth.config.queue_count[IONIC_QTYPE_TXQ];
130 adapter->max_nrxqs_per_lif =
131 ident->lif.eth.config.queue_count[IONIC_QTYPE_RXQ];
133 nintrs = nlifs * 1 /* notifyq */;
135 if (nintrs > dev_nintrs) {
136 IONIC_PRINT(ERR, "At most %d intr queues supported, minimum required is %u",
141 adapter->nintrs = nintrs;