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 D623C46005; Tue, 7 Jan 2025 03:50:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10A0F40DD6; Tue, 7 Jan 2025 03:50:10 +0100 (CET) Received: from lf-1-33.ptr.blmpb.com (lf-1-33.ptr.blmpb.com [103.149.242.33]) by mails.dpdk.org (Postfix) with ESMTP id 659DA40BA2 for ; Tue, 7 Jan 2025 03:50:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1736218199; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=GOUSrf+yb0Oo7zUjuwyNHEkx4EjkIzI67Av4G6BlFt8=; b=j+nmiQ14VR2f45oBXHajeoX9fU9g3I+XUQ2abPee/nyyVprYX2LmXFWTL1cmJ5qjd152xW R4PjpvTxlbd3chMwMkh2dOWbUGDv4nvhNTPD9n3dU8AR7Ri7GYNf6CT5Y7FxNKKjVcu+7B CUOv4e5azlUSVspV7Wb9WfA7Su2SPodA1wWe+UymXDfglr4DXwu+7x45XVdS6zwW6WOeTU TzsFAO4tksA5kWt+/62xRfm+dhrcWljLbZp/mCDPksN93nhoU+h/FyVGlwG2kMwdXLixF1 JaASFxZuh0D/AkgDtL8WQHW2KXnh5YZGrF9rJQ+Uunh1MFDOu1Und0NDM2YINg== From: "WanRenyong" Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Tue, 07 Jan 2025 10:49:54 +0800 Date: Tue, 07 Jan 2025 10:49:55 +0800 References: <20250107024939.1962467-1-wanry@yunsilicon.com> Content-Type: text/plain; charset=UTF-8 X-Lms-Return-Path: Cc: , , , , , , , , , Subject: [PATCH v5 07/15] net/xsc: add ethdev configure and RSS ops Mime-Version: 1.0 In-Reply-To: <20250107024939.1962467-1-wanry@yunsilicon.com> X-Mailer: git-send-email 2.25.1 To: Message-Id: <20250107024953.1962467-8-wanry@yunsilicon.com> X-Original-From: WanRenyong Content-Transfer-Encoding: 7bit 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 --- v5: * Remove some unnecessary parameter checks. --- 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 | 82 ++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.h | 7 +++ 6 files changed, 134 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 aaf18bf8e5..74d577c7d0 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 297c5d2324..2072f9ccb8 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..631d9c9819 100644 --- a/drivers/net/xsc/xsc_ethdev.c +++ b/drivers/net/xsc/xsc_ethdev.c @@ -9,6 +9,81 @@ #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->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; + + 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); + 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; + } + } + + 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 +110,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 +170,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