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 1F45E4595A; Wed, 11 Sep 2024 04:10:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8472B43251; Wed, 11 Sep 2024 04:08:28 +0200 (CEST) Received: from lf-1-13.ptr.blmpb.com (lf-1-13.ptr.blmpb.com [103.149.242.13]) by mails.dpdk.org (Postfix) with ESMTP id 47CED42FB1 for ; Wed, 11 Sep 2024 04:08:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1726020491; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=guudZXzc/qIc/XYPYoatNvikuZKiqe2qVRQhm5U6idQ=; b=TmWCeu7zw8T4IMLNdI1DrKXSPqEol461ZAn7u9sxKhVB8IsFZSpQH5hLcN37SG+W5CK/AT I5UPoMhhV9UuiXPxCwFe2wogd1Nyw0qNH7fPHxDkcC1Vy0hryIpzKrp7NCKdhsb5H/0HgI 3Mll5fQXLZYn+WNplEwXAnjQXOgYOw9fBcTvrbjveUjp1vdmQ2PNwrucp2iNigJdCQqFHG y9QmDmGNstEChcflISyJqG5DCxfN+7nBBbcgFChPlUCMxMaNPjTulJeo7xj70qwAEC0yZf W/j+mEvM1mCMFChKwo0HwUIeU7SHRjHsykYM06KHlJTRR7f84JSnrPvUMXFzkg== Message-Id: <20240911020740.3950704-13-wanry@yunsilicon.com> Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Wed, 11 Sep 2024 10:08:09 +0800 Content-Transfer-Encoding: 7bit X-Original-From: WanRenyong From: "WanRenyong" Subject: [PATCH v2 12/19] net/xsc: add ethdev RSS hash ops Date: Wed, 11 Sep 2024 10:07:33 +0800 To: Cc: , , "WanRenyong" X-Lms-Return-Path: Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1 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 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 a7259c5fcb..c33e625097 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 f21b105e83..25b2a4c44d 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