[RFC] net/ice: enable package download and RSS

Message ID 20190115133041.17556-1-qi.z.zhang@intel.com
State New
Delegated to: Ferruh Yigit
Headers show
Series
  • [RFC] net/ice: enable package download and RSS
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Zhang, Qi Z Jan. 15, 2019, 1:30 p.m.
This is RFC for customer early eveluation.
It depends on below patch set
http://patchwork.dpdk.org/project/dpdk/list/?series=3189

package download mechanism is hard coded as:
A file named "ice_os_default.pkg" at current directory will be downloaded
by driver during init stage.

Also RSS is enable for UPD/TCP/SCTP+IPV4/IPV6 flows.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 98 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index b145d9c64..3898be5ff 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2,9 +2,15 @@ 
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
 #include <rte_ethdev_pci.h>
 
 #include "base/ice_sched.h"
+#include "base/ice_flow.h"
 #include "ice_ethdev.h"
 #include "ice_rxtx.h"
 
@@ -1251,6 +1257,63 @@  ice_pf_setup(struct ice_pf *pf)
 	return 0;
 }
 
+static int ice_load_pkg(struct ice_pf *pf)
+{
+	struct ice_hw *hw = ICE_PF_TO_HW(pf);
+	int err;
+	uint8_t *buf;
+	int buf_len;
+	FILE *file;
+	struct stat fstat;
+
+	file = fopen("ice_os_default.pkg","rb");
+	if (file == NULL)  {
+		PMD_INIT_LOG(ERR, "failed to open file");
+		return 0;
+	}
+
+	err = stat("ice_os_default.pkg", &fstat);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to get file stats");
+		fclose(file);
+		return 0;
+	}
+
+	buf_len = fstat.st_size;
+	printf("buf_len = %d\n", buf_len);
+	buf = rte_malloc(NULL, buf_len, 0);
+
+	if (buf == NULL) {
+		PMD_INIT_LOG(ERR, "failed to allocate buf for package");
+		fclose(file);
+		return 0;
+	}
+
+	err = fread(buf, buf_len, 1, file);
+	if (err != 1) {
+		PMD_INIT_LOG(ERR, "failed to read package data");
+		fclose(file);
+		return 0;
+	}
+
+	fclose(file);
+
+	err = ice_copy_and_init_pkg(hw, buf, buf_len);
+	if (err) {
+		PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d\n",
+			err);
+		return err;
+	}
+
+	err = ice_init_hw_tbls(hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "ice_init_hw_tbls failed: %d\n", err);
+		return err;
+	}
+
+	return 0;
+}
+
 static int
 ice_dev_init(struct rte_eth_dev *dev)
 {
@@ -1314,6 +1377,11 @@  ice_dev_init(struct rte_eth_dev *dev)
 		goto err_pf_setup;
 	}
 
+	ret = ice_load_pkg(pf);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to load default OS package");
+	}
+
 	vsi = pf->main_vsi;
 
 	/* Disable double vlan by default */
@@ -1548,6 +1616,36 @@  static int ice_init_rss(struct ice_pf *pf)
 	if (ret)
 		return -EINVAL;
 
+	ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_TCP_IPV4,
+			      ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV4);
+	if (ret)
+		PMD_DRV_LOG(ERR, "%s TCP_IPV4 rss flow fail %d",__func__, ret);
+
+	ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_UDP_IPV4,
+				ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4);
+	if (ret)
+		PMD_DRV_LOG(ERR, "%s UDP_IPV4 rss flow fail %d",__func__, ret);
+
+	ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_SCTP_IPV4,
+				ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV4);
+	if (ret)
+		PMD_DRV_LOG(ERR, "%s SCTP_IPV4 rss flow fail %d",__func__, ret);
+
+	ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_TCP_IPV6,
+			ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV6);
+	if (ret)
+		PMD_DRV_LOG(ERR, "%s TCP_IPV6 rss flow fail %d",__func__, ret);
+
+	ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_UDP_IPV6,
+			ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV6);
+	if (ret)
+		PMD_DRV_LOG(ERR, "%s UDP_IPV6 flow fail %d",__func__, ret);
+
+	ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_SCTP_IPV6,
+			ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV6);
+	if (ret)
+		PMD_DRV_LOG(ERR, "%s SCTP_IPV6 rss flow fail %d",__func__, ret);
+
 	return 0;
 }