DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 12/19] net/xsc: add ethdev RSS hash ops
@ 2024-09-06 12:13 WanRenyong
  0 siblings, 0 replies; only message in thread
From: WanRenyong @ 2024-09-06 12:13 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, nana, WanRenyong

Implement xsc ethdev RSS hash config get and update functions.

Signed-off-by: WanRenyong <wanry@yunsilicon.com>
---
 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 5ad9567eb3..1f09ab9735 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 <ethdev_pci.h>
 
+#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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-06 12:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06 12:13 [PATCH 12/19] net/xsc: add ethdev RSS hash ops WanRenyong

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).