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 5957F459C3; Wed, 18 Sep 2024 08:11:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A30942EBE; Wed, 18 Sep 2024 08:10:08 +0200 (CEST) Received: from lf-2-37.ptr.blmpb.com (lf-2-37.ptr.blmpb.com [101.36.218.37]) by mails.dpdk.org (Postfix) with ESMTP id 26EAA42EA1 for ; Wed, 18 Sep 2024 08:10:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1726639800; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=HnQh0DuxvbxW8v5VFgJepwH4kDun8I34EC12osDA8Tc=; b=KO/j/lyHneHjRD24VuCcwWPSq3/AauRikMEg1nFYjRUNlM9io7IOOLoQgfwX5S1DEGcpGE A/srZyGHTQ5yTQkE6GOvUhX73xu4Q3JN2LalmpETIM8FZEkIM6MZB0ezfReSZpgHC3fDzu x/bwjd2RWSW/2jykFkbw0CbBlHrd2UHniGRKEge4nC1Ka2eRidtyVSb6lLcsins3aBU20o iE1FBeTqoWo+0lY0E8DMFH1EM1cXsG42gK6a0QgAJFw01p3jK6faLjMvZAC0tBBASo29ui JiJ09oydn8d63TrLh8x1u+G/zNuxKxyZ81/YAyjiKzKr4OehTIEXqLDyD8qhDw== To: Cc: , "WanRenyong" From: "WanRenyong" Message-Id: <20240918060936.1231758-13-wanry@yunsilicon.com> X-Lms-Return-Path: X-Mailer: git-send-email 2.25.1 Content-Type: text/plain; charset=UTF-8 Mime-Version: 1.0 X-Original-From: WanRenyong Subject: [PATCH v3 12/19] net/xsc: add ethdev RSS hash ops Date: Wed, 18 Sep 2024 14:09:29 +0800 Content-Transfer-Encoding: 7bit Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Wed, 18 Sep 2024 14:09:58 +0800 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 RSS hash config get and update functions. Signed-off-by: WanRenyong --- doc/guides/nics/features/xsc.ini | 3 +++ drivers/net/xsc/xsc_ctrl.h | 27 ++++++++++++++++++++ drivers/net/xsc/xsc_ethdev.c | 43 +++++++++++++++++++++++++++++++- drivers/net/xsc/xsc_ethdev.h | 17 +++++++++++++ drivers/net/xsc/xsc_utils.h | 5 +++- 5 files changed, 93 insertions(+), 2 deletions(-) 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_ctrl.h b/drivers/net/xsc/xsc_ctrl.h index 7b4d9db9ed..5c90d01b54 100644 --- a/drivers/net/xsc/xsc_ctrl.h +++ b/drivers/net/xsc/xsc_ctrl.h @@ -69,6 +69,33 @@ struct xsc_ioctl_mbox_out { uint8_t data[]; }; +struct xsc_nic_attr { + __be16 caps; + __be16 caps_mask; + uint8_t mac_addr[6]; +}; + +struct xsc_rss_modify_attr { + uint8_t caps_mask; + uint8_t rss_en; + __be16 rqn_base; + __be16 rqn_num; + uint8_t hfunc; + __be32 hash_tmpl; + uint8_t hash_key[52]; +}; + +struct xsc_cmd_modify_nic_hca_mbox_in { + struct xsc_inbox_hdr hdr; + struct xsc_nic_attr nic; + struct xsc_rss_modify_attr rss; +}; + +struct xsc_cmd_modify_nic_hca_mbox_out { + struct xsc_outbox_hdr hdr; + uint8_t rsvd0[4]; +}; + struct xsc_ioctl_data_tl { uint16_t table; uint16_t opmod; diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c index 3c38a9e93e..b0daca624f 100644 --- a/drivers/net/xsc/xsc_ethdev.c +++ b/drivers/net/xsc/xsc_ethdev.c @@ -17,6 +17,45 @@ static int xsc_rss_modify_cmd(struct xsc_ethdev_priv *priv, 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 |= BIT(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(BIT(XSC_TBM_CAP_RSS)); + in.nic.caps = in.nic.caps_mask; + + ret = xsc_mailbox_exec(priv->xdev, &in, sizeof(in), &out, sizeof(out)); + if (ret != 0 || out.hdr.status != 0) + return -1; + return 0; +} + +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; } @@ -30,7 +69,7 @@ xsc_ethdev_rss_hash_update(struct rte_eth_dev *dev, 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); + rss_conf->rss_key_len, XSC_RSS_HASH_KEY_LEN); return -EINVAL; } @@ -184,6 +223,8 @@ const struct eth_dev_ops xsc_dev_ops = { .dev_configure = xsc_ethdev_configure, .rx_queue_setup = xsc_ethdev_rx_queue_setup, .tx_queue_setup = xsc_ethdev_tx_queue_setup, + .rss_hash_update = xsc_ethdev_rss_hash_update, + .rss_hash_conf_get = xsc_ethdev_rss_hash_conf_get, }; static int diff --git a/drivers/net/xsc/xsc_ethdev.h b/drivers/net/xsc/xsc_ethdev.h index 10c3d8cc87..fb92d47dd0 100644 --- a/drivers/net/xsc/xsc_ethdev.h +++ b/drivers/net/xsc/xsc_ethdev.h @@ -9,6 +9,8 @@ #define XSC_MAX_DESC_NUMBER 1024 #define XSC_RX_FREE_THRESH 32 +#define XSC_CMD_OP_MODIFY_NIC_HCA 0x812 + struct xsc_dev_config { uint8_t pph_flag; unsigned int hw_csum:1; @@ -51,4 +53,19 @@ struct xsc_ethdev_priv { #define TO_XSC_ETHDEV_PRIV(dev) \ ((struct xsc_ethdev_priv *)(dev)->data->dev_private) +enum { + XSC_TBM_CAP_HASH_PPH = 0, + XSC_TBM_CAP_RSS, + XSC_TBM_CAP_PP_BYPASS, + XSC_TBM_CAP_PCT_DROP_CONFIG, +}; + +enum { + 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_ETHDEV_H_ */ diff --git a/drivers/net/xsc/xsc_utils.h b/drivers/net/xsc/xsc_utils.h index 8d08cf75b7..672ba3871e 100644 --- a/drivers/net/xsc/xsc_utils.h +++ b/drivers/net/xsc/xsc_utils.h @@ -9,6 +9,10 @@ #include +#ifndef BIT +#define BIT(n) (1UL << (n)) +#endif + struct ibv_device *xsc_get_ibv_device(const struct rte_pci_addr *addr); int xsc_get_ifname_by_pci_addr(struct rte_pci_addr *addr, char *ifname); int xsc_get_ifindex_by_ifname(const char *ifname, int *ifindex); @@ -19,5 +23,4 @@ int xsc_get_mtu(uint16_t *mtu, uint32_t ifindex); int xsc_set_mtu(uint16_t mtu, uint32_t ifindex); int xsc_get_mac(uint8_t *mac, uint32_t ifindex); - #endif -- 2.25.1