From: Yanling Song <songyl@ramaxel.com>
To: <dev@dpdk.org>
Cc: <songyl@ramaxel.com>, <yanling.song@linux.dev>,
<yanggan@ramaxel.com>, <xuyun@ramaxel.com>,
<ferruh.yigit@intel.com>, <stephen@networkplumber.org>,
<lihuisong@huawei.com>
Subject: [PATCH v6 16/26] net/spnic: add device configure/version/info
Date: Thu, 30 Dec 2021 14:08:54 +0800 [thread overview]
Message-ID: <e2173c7336fa899e2da3b77aecaa0f86358236bd.1640838702.git.songyl@ramaxel.com> (raw)
In-Reply-To: <cover.1640838702.git.songyl@ramaxel.com>
This commit adds the callbacks to configure queue number and mtu
as well as query configuration information and firmware version.
Signed-off-by: Yanling Song <songyl@ramaxel.com>
---
drivers/net/spnic/spnic_ethdev.c | 129 ++++++++++++++++++++++++++++++-
1 file changed, 127 insertions(+), 2 deletions(-)
diff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c
index e7552f7286..531a094445 100644
--- a/drivers/net/spnic/spnic_ethdev.c
+++ b/drivers/net/spnic/spnic_ethdev.c
@@ -71,12 +71,131 @@ enum spnic_rx_mod {
#define SPNIC_TXD_ALIGN 1
#define SPNIC_RXD_ALIGN 1
+static const struct rte_eth_desc_lim spnic_rx_desc_lim = {
+ .nb_max = SPNIC_MAX_QUEUE_DEPTH,
+ .nb_min = SPNIC_MIN_QUEUE_DEPTH,
+ .nb_align = SPNIC_RXD_ALIGN,
+};
+
+static const struct rte_eth_desc_lim spnic_tx_desc_lim = {
+ .nb_max = SPNIC_MAX_QUEUE_DEPTH,
+ .nb_min = SPNIC_MIN_QUEUE_DEPTH,
+ .nb_align = SPNIC_TXD_ALIGN,
+};
+
/**
- * Deinit mac_vlan table in hardware.
+ * Ethernet device configuration.
*
- * @param[in] eth_dev
+ * Prepare the driver for a given number of TX and RX queues, mtu size
+ * and configure RSS.
+ *
+ * @param[in] dev
+ * Pointer to ethernet device structure.
+ *
+ * @retval zero : Success
+ * @retval non-zero : Failure.
+ */
+static int spnic_dev_configure(struct rte_eth_dev *dev)
+{
+ struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+
+ nic_dev->num_sqs = dev->data->nb_tx_queues;
+ nic_dev->num_rqs = dev->data->nb_rx_queues;
+
+ nic_dev->mtu_size =
+ SPNIC_PKTLEN_TO_MTU(dev->data->dev_conf.rxmode.mtu);
+
+ if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+ dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
+ return 0;
+}
+
+/**
+ * Get information about the device.
+ *
+ * @param[in] dev
* Pointer to ethernet device structure.
+ * @param[out] info
+ * Info structure for ethernet device.
+ *
+ * @retval zero : Success
+ * @retval non-zero : Failure.
*/
+static int spnic_dev_infos_get(struct rte_eth_dev *dev,
+ struct rte_eth_dev_info *info)
+{
+ struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+
+ info->max_rx_queues = nic_dev->max_rqs;
+ info->max_tx_queues = nic_dev->max_sqs;
+ info->min_rx_bufsize = SPNIC_MIN_RX_BUF_SIZE;
+ info->max_rx_pktlen = SPNIC_MAX_JUMBO_FRAME_SIZE;
+ info->max_mac_addrs = SPNIC_MAX_UC_MAC_ADDRS;
+ info->min_mtu = SPNIC_MIN_MTU_SIZE;
+ info->max_mtu = SPNIC_MAX_MTU_SIZE;
+ info->max_lro_pkt_size = SPNIC_MAX_LRO_SIZE;
+
+ info->rx_queue_offload_capa = 0;
+ info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+ DEV_RX_OFFLOAD_IPV4_CKSUM |
+ DEV_RX_OFFLOAD_UDP_CKSUM |
+ DEV_RX_OFFLOAD_TCP_CKSUM |
+ DEV_RX_OFFLOAD_SCTP_CKSUM |
+ DEV_RX_OFFLOAD_VLAN_FILTER |
+ DEV_RX_OFFLOAD_SCATTER |
+ DEV_RX_OFFLOAD_TCP_LRO |
+ DEV_RX_OFFLOAD_RSS_HASH;
+
+ info->tx_queue_offload_capa = 0;
+ info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
+ DEV_TX_OFFLOAD_IPV4_CKSUM |
+ DEV_TX_OFFLOAD_UDP_CKSUM |
+ DEV_TX_OFFLOAD_TCP_CKSUM |
+ DEV_TX_OFFLOAD_SCTP_CKSUM |
+ DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+ DEV_TX_OFFLOAD_TCP_TSO |
+ DEV_TX_OFFLOAD_MULTI_SEGS;
+
+ info->hash_key_size = SPNIC_RSS_KEY_SIZE;
+ info->reta_size = SPNIC_RSS_INDIR_SIZE;
+ info->flow_type_rss_offloads = SPNIC_RSS_OFFLOAD_ALL;
+
+ info->rx_desc_lim = spnic_rx_desc_lim;
+ info->tx_desc_lim = spnic_tx_desc_lim;
+
+ /* Driver-preferred rx/tx parameters */
+ info->default_rxportconf.burst_size = SPNIC_DEFAULT_BURST_SIZE;
+ info->default_txportconf.burst_size = SPNIC_DEFAULT_BURST_SIZE;
+ info->default_rxportconf.nb_queues = SPNIC_DEFAULT_NB_QUEUES;
+ info->default_txportconf.nb_queues = SPNIC_DEFAULT_NB_QUEUES;
+ info->default_rxportconf.ring_size = SPNIC_DEFAULT_RING_SIZE;
+ info->default_txportconf.ring_size = SPNIC_DEFAULT_RING_SIZE;
+
+ return 0;
+}
+
+static int spnic_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+ size_t fw_size)
+{
+ struct spnic_nic_dev *nic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+ char mgmt_ver[MGMT_VERSION_MAX_LEN] = { 0 };
+ int err;
+
+ err = spnic_get_mgmt_version(nic_dev->hwdev, mgmt_ver,
+ SPNIC_MGMT_VERSION_MAX_LEN);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Get fw version failed");
+ return -EIO;
+ }
+
+ if (fw_size < strlen(mgmt_ver) + 1)
+ return (strlen(mgmt_ver) + 1);
+
+ snprintf(fw_version, fw_size, "%s", mgmt_ver);
+
+ return 0;
+}
/**
* Set ethernet device link state up.
@@ -1332,6 +1451,9 @@ static int spnic_set_mc_addr_list(struct rte_eth_dev *dev,
}
static const struct eth_dev_ops spnic_pmd_ops = {
+ .dev_configure = spnic_dev_configure,
+ .dev_infos_get = spnic_dev_infos_get,
+ .fw_version_get = spnic_fw_version_get,
.dev_set_link_up = spnic_dev_set_link_up,
.dev_set_link_down = spnic_dev_set_link_down,
.link_update = spnic_link_update,
@@ -1350,6 +1472,9 @@ static const struct eth_dev_ops spnic_pmd_ops = {
};
static const struct eth_dev_ops spnic_pmd_vf_ops = {
+ .dev_configure = spnic_dev_configure,
+ .dev_infos_get = spnic_dev_infos_get,
+ .fw_version_get = spnic_fw_version_get,
.rx_queue_setup = spnic_rx_queue_setup,
.tx_queue_setup = spnic_tx_queue_setup,
.dev_start = spnic_dev_start,
--
2.32.0
next prev parent reply other threads:[~2021-12-30 6:11 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-30 6:08 [PATCH v6 00/26] Net/SPNIC: support SPNIC into DPDK 22.03 Yanling Song
2021-12-30 6:08 ` [PATCH v6 01/26] drivers/net: introduce a new PMD driver Yanling Song
2022-01-19 16:58 ` Ferruh Yigit
2021-12-30 6:08 ` [PATCH v6 02/26] net/spnic: initialize the HW interface Yanling Song
2022-01-19 17:05 ` Ferruh Yigit
2022-01-21 9:32 ` Yanling Song
2021-12-30 6:08 ` [PATCH v6 03/26] net/spnic: add mbox message channel Yanling Song
2021-12-30 6:08 ` [PATCH v6 04/26] net/spnic: introduce event queue Yanling Song
2021-12-30 6:08 ` [PATCH v6 05/26] net/spnic: add mgmt module Yanling Song
2022-01-19 17:22 ` Ferruh Yigit
2022-01-21 9:33 ` Yanling Song
2021-12-30 6:08 ` [PATCH v6 06/26] net/spnic: add cmdq and work queue Yanling Song
2021-12-30 6:08 ` [PATCH v6 07/26] net/spnic: add interface handling cmdq message Yanling Song
2021-12-30 6:08 ` [PATCH v6 08/26] net/spnic: add hardware info initialization Yanling Song
2021-12-30 6:08 ` [PATCH v6 09/26] net/spnic: support MAC and link event handling Yanling Song
2022-01-19 17:26 ` Ferruh Yigit
2022-01-21 9:36 ` Yanling Song
2021-12-30 6:08 ` [PATCH v6 10/26] net/spnic: add function info initialization Yanling Song
2021-12-30 6:08 ` [PATCH v6 11/26] net/spnic: add queue pairs context initialization Yanling Song
2021-12-30 6:08 ` [PATCH v6 12/26] net/spnic: support mbuf handling of Tx/Rx Yanling Song
2021-12-30 6:08 ` [PATCH v6 13/26] net/spnic: support Rx congfiguration Yanling Song
2021-12-30 6:08 ` [PATCH v6 14/26] net/spnic: add port/vport enable Yanling Song
2021-12-30 6:08 ` [PATCH v6 15/26] net/spnic: support IO packets handling Yanling Song
2021-12-30 6:08 ` Yanling Song [this message]
2021-12-30 6:08 ` [PATCH v6 17/26] net/spnic: support RSS configuration update and get Yanling Song
2021-12-30 6:08 ` [PATCH v6 18/26] net/spnic: support VLAN filtering and offloading Yanling Song
2021-12-30 6:08 ` [PATCH v6 19/26] net/spnic: support promiscuous and allmulticast Rx modes Yanling Song
2021-12-30 6:08 ` [PATCH v6 20/26] net/spnic: support flow control Yanling Song
2021-12-30 6:08 ` [PATCH v6 21/26] net/spnic: support getting Tx/Rx queues info Yanling Song
2021-12-30 6:09 ` [PATCH v6 22/26] net/spnic: net/spnic: support xstats statistics Yanling Song
2021-12-30 6:09 ` [PATCH v6 23/26] net/spnic: support VFIO interrupt Yanling Song
2021-12-30 6:09 ` [PATCH v6 24/26] net/spnic: support Tx/Rx queue start/stop Yanling Song
2021-12-30 6:09 ` [PATCH v6 25/26] net/spnic: add doc infrastructure Yanling Song
2022-01-19 17:27 ` Ferruh Yigit
2022-01-21 9:39 ` Yanling Song
2021-12-30 6:09 ` [PATCH v6 26/26] net/spnic: fixes unsafe C style code Yanling Song
2022-01-19 17:28 ` Ferruh Yigit
2022-01-21 9:40 ` Yanling Song
2022-01-19 16:56 ` [PATCH v6 00/26] Net/SPNIC: support SPNIC into DPDK 22.03 Ferruh Yigit
2022-01-21 9:27 ` Yanling Song
2022-01-21 10:22 ` Ferruh Yigit
2022-01-24 5:12 ` Hemant Agrawal
2022-02-12 14:01 ` Yanling Song
2022-02-13 18:07 ` Thomas Monjalon
2022-02-18 9:30 ` Yanling Song
2023-04-13 9:02 ` Ferruh Yigit
2023-07-31 14:08 ` Thomas Monjalon
2022-02-16 14:19 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2173c7336fa899e2da3b77aecaa0f86358236bd.1640838702.git.songyl@ramaxel.com \
--to=songyl@ramaxel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=lihuisong@huawei.com \
--cc=stephen@networkplumber.org \
--cc=xuyun@ramaxel.com \
--cc=yanggan@ramaxel.com \
--cc=yanling.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).