From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B739C45FD7; Fri, 3 Jan 2025 16:04:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26D724060A; Fri, 3 Jan 2025 16:04:30 +0100 (CET) Received: from lf-2-53.ptr.blmpb.com (lf-2-53.ptr.blmpb.com [101.36.218.53]) by mails.dpdk.org (Postfix) with ESMTP id 5657140654 for ; Fri, 3 Jan 2025 16:04:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1735916662; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=cG75KFeCT5fuil8YpljlWjZM5LEP8aoqoDlaeaqC9so=; b=XbYGzJhCD4AH5+etTP1k7+00f8wY1Ct7URWCyAxIUhECHGvch+Q3JqyBfAWRlbdzE4Ze0D jHzfQ8gooD1okgFzzMT+LAV0NmfB0oBwYugERPVzgANRKHtlEY2Qa1rKRLBpwWfl8SQLK0 YCzCH0DWyHZukohOwNuxB8Ao2yjEZ0L2mKpOXPVvozd48w1EhebX39kTf2Iqnrlyq6TBXQ 5oJ+fgOje7fTQwjav3+Q+hue01TMkzanUhYcxXFmwsLYbYtmoPRCJG5saKWyBweZMTlNxn Iq1nB+3dM9JrbJ//eySMLDMaU1oVwdW0qa4b4gJqLrXkrOdQJd4AyBJCVslSgw== X-Original-From: WanRenyong References: <20250103150404.1529663-1-wanry@yunsilicon.com> Content-Transfer-Encoding: 7bit Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Fri, 03 Jan 2025 23:04:19 +0800 From: "WanRenyong" Date: Fri, 03 Jan 2025 23:04:19 +0800 Message-Id: <20250103150418.1529663-8-wanry@yunsilicon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250103150404.1529663-1-wanry@yunsilicon.com> To: Cc: , , , , , , , , , Subject: [PATCH v4 07/15] net/xsc: add ethdev configure and RSS ops Mime-Version: 1.0 X-Lms-Return-Path: Content-Type: text/plain; charset=UTF-8 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Implement xsc ethdev configure and RSS hash functions. Signed-off-by: WanRenyong --- doc/guides/nics/features/xsc.ini | 3 + drivers/net/xsc/xsc_defs.h | 15 +++++ drivers/net/xsc/xsc_dev.c | 26 ++++++++ drivers/net/xsc/xsc_dev.h | 1 + drivers/net/xsc/xsc_ethdev.c | 106 +++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 7 ++ 6 files changed, 158 insertions(+) diff --git a/doc/guides/nics/features/xsc.ini b/doc/guides/nics/features/xsc.ini index b5c44ce535..bdeb7a984b 100644 --- a/doc/guides/nics/features/xsc.ini +++ b/doc/guides/nics/features/xsc.ini @@ -4,6 +4,9 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +RSS hash = Y +RSS key update = Y +RSS reta update = Y Linux = Y ARMv8 = Y x86-64 = Y diff --git a/drivers/net/xsc/xsc_defs.h b/drivers/net/xsc/xsc_defs.h index 111776f37e..c445eadca1 100644 --- a/drivers/net/xsc/xsc_defs.h +++ b/drivers/net/xsc/xsc_defs.h @@ -78,4 +78,19 @@ enum xsc_port_type { XSC_PORT_TYPE_UNKNOWN, }; +enum xsc_tbm_cap { + XSC_TBM_CAP_HASH_PPH = 0, + XSC_TBM_CAP_RSS, + XSC_TBM_CAP_PP_BYPASS, + XSC_TBM_CAP_PCT_DROP_CONFIG, +}; + +enum xsc_rss_hf { + XSC_RSS_HASH_KEY_UPDATE = 0, + XSC_RSS_HASH_TEMP_UPDATE, + XSC_RSS_HASH_FUNC_UPDATE, + XSC_RSS_RXQ_UPDATE, + XSC_RSS_RXQ_DROP, +}; + #endif /* XSC_DEFS_H_ */ diff --git a/drivers/net/xsc/xsc_dev.c b/drivers/net/xsc/xsc_dev.c index 71d7ab7ea4..84bab2bb93 100644 --- a/drivers/net/xsc/xsc_dev.c +++ b/drivers/net/xsc/xsc_dev.c @@ -19,6 +19,7 @@ #include "xsc_log.h" #include "xsc_defs.h" #include "xsc_dev.h" +#include "xsc_cmd.h" #define XSC_DEV_DEF_FLOW_MODE 7 @@ -74,6 +75,31 @@ xsc_dev_close(struct xsc_dev *xdev, int repr_id) return xdev->dev_ops->dev_close(xdev); } +int +xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len) +{ + struct xsc_cmd_modify_nic_hca_mbox_in in = {}; + struct xsc_cmd_modify_nic_hca_mbox_out out = {}; + uint8_t rss_caps_mask = 0; + int ret, key_len = 0; + + in.hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_MODIFY_NIC_HCA); + + key_len = RTE_MIN(rss_key_len, XSC_RSS_HASH_KEY_LEN); + rte_memcpy(in.rss.hash_key, rss_key, key_len); + rss_caps_mask |= RTE_BIT32(XSC_RSS_HASH_KEY_UPDATE); + + in.rss.caps_mask = rss_caps_mask; + in.rss.rss_en = 1; + in.nic.caps_mask = rte_cpu_to_be_16(RTE_BIT32(XSC_TBM_CAP_RSS)); + in.nic.caps = in.nic.caps_mask; + + ret = xsc_dev_mailbox_exec(xdev, &in, sizeof(in), &out, sizeof(out)); + if (ret != 0 || out.hdr.status != 0) + return -1; + return 0; +} + static int xsc_dev_alloc_vfos_info(struct xsc_dev *xdev) { diff --git a/drivers/net/xsc/xsc_dev.h b/drivers/net/xsc/xsc_dev.h index 9010225a20..3bebb18b98 100644 --- a/drivers/net/xsc/xsc_dev.h +++ b/drivers/net/xsc/xsc_dev.h @@ -162,6 +162,7 @@ int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev); void xsc_dev_uninit(struct xsc_dev *xdev); int xsc_dev_close(struct xsc_dev *xdev, int repr_id); int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_eth_ports); +int xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len); bool xsc_dev_is_vf(struct xsc_dev *xdev); int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id); int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac); diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c index 9fc5464754..81ac062862 100644 --- a/drivers/net/xsc/xsc_ethdev.c +++ b/drivers/net/xsc/xsc_ethdev.c @@ -9,6 +9,105 @@ #include "xsc_defs.h" #include "xsc_ethdev.h" +static int +xsc_ethdev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + + if (!rss_conf) { + rte_errno = EINVAL; + return -rte_errno; + } + + if (rss_conf->rss_key != NULL && rss_conf->rss_key_len >= priv->rss_conf.rss_key_len) + memcpy(rss_conf->rss_key, priv->rss_conf.rss_key, priv->rss_conf.rss_key_len); + + rss_conf->rss_key_len = priv->rss_conf.rss_key_len; + rss_conf->rss_hf = priv->rss_conf.rss_hf; + return 0; +} + +static int +xsc_ethdev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + int ret = 0; + + if (rss_conf->rss_key_len > XSC_RSS_HASH_KEY_LEN || rss_conf->rss_key == NULL) { + PMD_DRV_LOG(ERR, "Xsc pmd key len is %d bigger than %d", + rss_conf->rss_key_len, XSC_RSS_HASH_KEY_LEN); + return -EINVAL; + } + + ret = xsc_dev_rss_key_modify(priv->xdev, rss_conf->rss_key, rss_conf->rss_key_len); + if (ret == 0) { + rte_memcpy(priv->rss_conf.rss_key, rss_conf->rss_key, + priv->rss_conf.rss_key_len); + priv->rss_conf.rss_key_len = rss_conf->rss_key_len; + priv->rss_conf.rss_hf = rss_conf->rss_hf; + } + + return ret; +} + +static int +xsc_ethdev_configure(struct rte_eth_dev *dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; + int ret; + struct rte_eth_rss_conf *rss_conf; + + priv->num_sq = dev->data->nb_tx_queues; + priv->num_rq = dev->data->nb_rx_queues; + + if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) + dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH; + + if (priv->rss_conf.rss_key == NULL) { + priv->rss_conf.rss_key = rte_zmalloc(NULL, XSC_RSS_HASH_KEY_LEN, + RTE_CACHE_LINE_SIZE); + if (priv->rss_conf.rss_key == NULL) { + PMD_DRV_LOG(ERR, "Failed to alloc rss key"); + rte_errno = ENOMEM; + ret = -rte_errno; + goto error; + } + priv->rss_conf.rss_key_len = XSC_RSS_HASH_KEY_LEN; + } + + if (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key != NULL) { + rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf; + ret = xsc_ethdev_rss_hash_update(dev, rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Xsc pmd set rss key error!"); + rte_errno = -ENOEXEC; + goto error; + } + } + + if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) { + PMD_DRV_LOG(ERR, "Xsc pmd do not support vlan filter now!"); + rte_errno = EINVAL; + goto error; + } + + if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) { + PMD_DRV_LOG(ERR, "Xsc pmd do not support vlan strip now!"); + rte_errno = EINVAL; + goto error; + } + + priv->txqs = (void *)dev->data->tx_queues; + priv->rxqs = (void *)dev->data->rx_queues; + return 0; + +error: + return -rte_errno; +} + static int xsc_ethdev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t index) { @@ -35,6 +134,12 @@ xsc_ethdev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uin return 0; } +const struct eth_dev_ops xsc_eth_dev_ops = { + .dev_configure = xsc_ethdev_configure, + .rss_hash_update = xsc_ethdev_rss_hash_update, + .rss_hash_conf_get = xsc_ethdev_rss_hash_conf_get, +}; + static int xsc_ethdev_init_one_representor(struct rte_eth_dev *eth_dev, void *init_params) { @@ -89,6 +194,7 @@ xsc_ethdev_init_one_representor(struct rte_eth_dev *eth_dev, void *init_params) eth_dev->data->backer_port_id = eth_dev->data->port_id; } + eth_dev->dev_ops = &xsc_eth_dev_ops; eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy; eth_dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; diff --git a/drivers/net/xsc/xsc_ethdev.h b/drivers/net/xsc/xsc_ethdev.h index 7d161bd22e..bc0fc54d50 100644 --- a/drivers/net/xsc/xsc_ethdev.h +++ b/drivers/net/xsc/xsc_ethdev.h @@ -30,6 +30,13 @@ struct xsc_ethdev_priv { uint16_t eth_type; uint16_t qp_set_id; + + uint16_t num_sq; + uint16_t num_rq; + + uint16_t flags; + struct xsc_txq_data *(*txqs)[]; + struct xsc_rxq_data *(*rxqs)[]; }; #define TO_XSC_ETHDEV_PRIV(dev) ((struct xsc_ethdev_priv *)(dev)->data->dev_private) -- 2.25.1