Skip to contentSkip to conversation

Add iecm and idpf

PATCH New Alan Brady 6 participants 83 messages Jan 28, 2022 – Feb 4, 2022 Page 5 of 5

Subsystems (4)
lore
Share & tools
lore
#74 lore raw

PATCH 18/19 iecm: add advanced rss

In reply to Alan Brady

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:08 -0800

Quoted 4 lines

From: Haiyue Wang <[email protected]>

Continuing with advanced features this implements what's needed to do advanced rss.

I'm sorry for not mentioned it before, but most of the series' commit messages are poor and would probably get rejected upstream. If they were explaining at least some very basics, it would be better. Even better if there were explanations of some tricky code that happens time to time.

Quoted 25 lines
---
 drivers/net/ethernet/intel/iecm/iecm_lib.c    | 547 ++++++++++++++++++
 .../net/ethernet/intel/iecm/iecm_virtchnl.c   |  71 +++
 drivers/net/ethernet/intel/include/iecm.h     |  73 +++
 3 files changed, 691 insertions(+)
drivers/net/ethernet/intel/iecm/iecm_lib.c +9 -0
index d11413cb438c..baa1e312652a 100644
@@ -1013,6 +1013,52 @@ static void iecm_remove_vlan_filters(struct iecm_vport *vport)
 	}
 }
 
+/**
+ * iecm_remove_adv_rss_cfgs - Remove all RSS configuration
+ * @vport: vport structure
+ */
+static void iecm_remove_adv_rss_cfgs(struct iecm_vport *vport)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS, VIRTCHNL2_CAP_ADV_RSS))

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1034

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+		return;
+
+	if (!list_empty(&adapter->config_data.adv_rss_list)) {
+		struct iecm_adv_rss *rss;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter->config_data.adv_rss_list,
+				    list) {
+			rss->remove = true;
+		}

Redundant braces arond an one-liner.

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1037

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+		iecm_send_add_del_adv_rss_cfg_msg(vport, false);
+	}

Invert the condition for -1 indent level.

Quoted 55 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +41 -0
+}
+
+/**
+ * iecm_del_all_adv_rss_cfgs - delete all RSS configuration
+ * @vport: vport structure
+ *
+ * This function will loop through the list of RSS configuration and deletes
+ * them.
+ **/
+static void iecm_del_all_adv_rss_cfgs(struct iecm_vport *vport)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss, *rss_tmp;
+
+	spin_lock_bh(&adapter->adv_rss_list_lock);
+	list_for_each_entry_safe(rss, rss_tmp,
+				 &adapter->config_data.adv_rss_list,
+				 list) {
+		list_del(&rss->list);
+		kfree(rss);
+	}
+	spin_unlock_bh(&adapter->adv_rss_list_lock);
+}
+
 /**
  * iecm_remove_fdir_filters - Remove all Flow Director filters
  * @vport: vport structure
@@ -1099,6 +1145,7 @@ static void iecm_vport_stop(struct iecm_vport *vport)
 		iecm_remove_vlan_filters(vport);
 	}
 
+	iecm_remove_adv_rss_cfgs(vport);
 	iecm_remove_fdir_filters(vport);
 
 	adapter->link_up = false;
@@ -1332,6 +1379,27 @@ static void iecm_restore_cloud_filters(struct iecm_vport *vport)
 	}
 }
 
+/**
+ * iecm_restore_adv_rss_cfgs - Restore all RSS configuration
+ * @vport: vport structure
+ */
+static void iecm_restore_adv_rss_cfgs(struct iecm_vport *vport)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+
+	if (!list_empty(&adapter->config_data.adv_rss_list)) {
+		struct iecm_adv_rss *rss;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter->config_data.adv_rss_list,
+				    list) {
+			rss->add = true;
+		}

...

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+		iecm_send_add_del_adv_rss_cfg_msg(vport, true);
+	}

...

Quoted 187 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +166 -0
+}
+
 /**
  * iecm_restore_fdir_filters - Restore all Flow Director filters
  * @vport: vport structure
@@ -1380,6 +1448,9 @@ static void iecm_restore_features(struct iecm_vport *vport)
 	if (iecm_is_feature_ena(vport, NETIF_F_HW_TC))
 		iecm_restore_cloud_filters(vport);
 
+	if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS, VIRTCHNL2_CAP_ADV_RSS))
+		iecm_restore_adv_rss_cfgs(vport);
+
 	if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS, VIRTCHNL2_CAP_FDIR))
 		iecm_restore_fdir_filters(vport);
 }
@@ -2219,6 +2290,7 @@ static void iecm_del_user_cfg_data(struct iecm_adapter *adapter)
 		if (!adapter->vports[i])
 			continue;
 
+		iecm_del_all_adv_rss_cfgs(adapter->vports[i]);
 		iecm_del_all_fdir_filters(adapter->vports[i]);
 	}
 }
@@ -3633,6 +3705,481 @@ static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,
 	return err;
 }
 
+/**
+ * iecm_fill_adv_rss_ip4_hdr - fill the IPv4 RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields
+ */
+static void
+iecm_fill_adv_rss_ip4_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)
+{
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV4);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV4_SA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, SRC);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV4_DA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, DST);
+}
+
+/**
+ * iecm_fill_adv_rss_ip6_hdr - fill the IPv6 RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields
+ */
+static void
+iecm_fill_adv_rss_ip6_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)
+{
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV6);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV6_SA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, SRC);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV6_DA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, DST);
+}
+
+/**
+ * iecm_fill_adv_rss_tcp_hdr - fill the TCP RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields
+ */
+static void
+iecm_fill_adv_rss_tcp_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)
+{
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, TCP);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP, SRC_PORT);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP, DST_PORT);
+}
+
+/**
+ * iecm_fill_adv_rss_udp_hdr - fill the UDP RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields
+ */
+static void
+iecm_fill_adv_rss_udp_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)
+{
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, UDP);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, UDP, SRC_PORT);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, UDP, DST_PORT);
+}
+
+/**
+ * iecm_fill_adv_rss_sctp_hdr - fill the SCTP RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields
+ */
+static void
+iecm_fill_adv_rss_sctp_hdr(struct virtchnl_proto_hdr *hdr, s64 hash_flds)
+{
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, SCTP);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, SCTP, SRC_PORT);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, SCTP, DST_PORT);
+}
+
+/**
+ * iecm_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl message
+ * @rss_cfg: the virtchnl message to be filled with RSS configuration setting
+ * @packet_hdrs: the RSS configuration protocol header types
+ * @hash_flds: the RSS configuration protocol hash fields
+ *
+ * Returns 0 if the RSS configuration virtchnl message is filled successfully
+ */
+static int
+iecm_fill_adv_rss_cfg_msg(struct virtchnl_rss_cfg *rss_cfg,
+			  u32 packet_hdrs, u64 hash_flds)
+{
+	struct virtchnl_proto_hdrs *proto_hdrs = &rss_cfg->proto_hdrs;
+	struct virtchnl_proto_hdr *hdr;
+
+	rss_cfg->rss_algorithm = VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC;
+
+	proto_hdrs->tunnel_level = 0;	/* always outer layer */
+
+	hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
+	switch (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_L3) {
+	case IECM_ADV_RSS_FLOW_SEG_HDR_IPV4:
+		iecm_fill_adv_rss_ip4_hdr(hdr, hash_flds);
+		break;
+	case IECM_ADV_RSS_FLOW_SEG_HDR_IPV6:
+		iecm_fill_adv_rss_ip6_hdr(hdr, hash_flds);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
+	switch (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_L4) {
+	case IECM_ADV_RSS_FLOW_SEG_HDR_TCP:
+		iecm_fill_adv_rss_tcp_hdr(hdr, hash_flds);
+		break;
+	case IECM_ADV_RSS_FLOW_SEG_HDR_UDP:
+		iecm_fill_adv_rss_udp_hdr(hdr, hash_flds);
+		break;
+	case IECM_ADV_RSS_FLOW_SEG_HDR_SCTP:
+		iecm_fill_adv_rss_sctp_hdr(hdr, hash_flds);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/**
+ * iecm_find_adv_rss_cfg_by_hdrs - find RSS configuration with header type
+ * @vport: vport structure
+ * @packet_hdrs: protocol header type to find.
+ *
+ * Returns pointer to advance RSS configuration if found or null
+ */
+static struct iecm_adv_rss *
+iecm_find_adv_rss_cfg_by_hdrs(struct iecm_vport *vport, u32 packet_hdrs)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss;
+
+	list_for_each_entry(rss, &adapter->config_data.adv_rss_list, list)
+		if (rss->packet_hdrs == packet_hdrs)
+			return rss;
+
+	return NULL;
+}
+
+/**
+ * iecm_dump_adv_rss_cfg_info
+ * @vport: vport structure
+ * @packet_hdrs: The protocol headers for RSS configuration
+ * @hash_flds: The protocol hash fields for RSS configuration
+ * @prefix: the prefix string description to dump the RSS

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3877

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+ * @postfix: the postfix string description to dump the RSS
+ *
+ * Dump the advance RSS configuration
+ **/
+static void
+iecm_dump_adv_rss_cfg_info(struct iecm_vport *vport,
+			   u32 packet_hdrs, u64 hash_flds,
+			   const char *prefix, const char *postfix)
+{
+	static char hash_opt[300];

static places it into BSS. If multiple cores call this function at the same time, it will mess up.
I'd just kzalloc() a buffer and then kfree() it.

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4 -0
+	const char *proto;
+
+	if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_TCP)
+		proto = "TCP";

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3891

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+	else if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_UDP)
+		proto = "UDP";
+	else if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_SCTP)
+		proto = "SCTP";
+	else
+		return;
+
+	memset(hash_opt, 0, sizeof(hash_opt));
+
+	strcat(hash_opt, proto);

Consider using strlcat() please.

Quoted 75 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +75 -0
+	if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_IPV4)
+		strcat(hash_opt, "v4 ");
+	else
+		strcat(hash_opt, "v6 ");
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_SA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_SA))
+		strcat(hash_opt, "[IP SA] ");
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_DA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_DA))
+		strcat(hash_opt, "[IP DA] ");
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT))
+		strcat(hash_opt, "[src port] ");
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT))
+		strcat(hash_opt, "[dst port] ");
+
+	if (!prefix)
+		prefix = "";
+
+	if (!postfix)
+		postfix = "";
+
+	dev_info(&vport->adapter->pdev->dev, "%s %s %s\n",
+		 prefix, hash_opt, postfix);
+}
+
+/**
+ * iecm_adv_rss_parse_hdrs - parses headers from RSS hash input
+ * @cmd: ethtool rxnfc command
+ *
+ * This function parses the rxnfc command and returns intended
+ * header types for RSS configuration
+ */
+static u32 iecm_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd)
+{
+	u32 hdrs = IECM_ADV_RSS_FLOW_SEG_HDR_NONE;
+
+	switch (cmd->flow_type) {
+	case TCP_V4_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_TCP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV4;
+		break;
+	case UDP_V4_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_UDP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV4;
+		break;
+	case SCTP_V4_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_SCTP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV4;
+		break;
+	case TCP_V6_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_TCP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV6;
+		break;
+	case UDP_V6_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_UDP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV6;
+		break;
+	case SCTP_V6_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_SCTP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV6;
+		break;
+	default:
+		break;
+	}
+
+	return hdrs;
+}
+
+/**
+ * iecm_adv_rss_parse_hash_flds - parses hash fields from RSS hash input

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3976

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+ * @cmd: ethtool rxnfc command
+ *
+ * This function parses the rxnfc command and returns intended hash fields for
+ * RSS configuration
+ */
+static u64 iecm_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)
+{
+	u64 hfld = IECM_ADV_RSS_HASH_INVALID;
+
+	if (cmd->data & RXH_IP_SRC || cmd->data & RXH_IP_DST) {

Braces are actually *needed* around bitops. So,

	if ((cmd->data & RXH_IP_SRC) || (...)) {
Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11 -0
+		switch (cmd->flow_type) {
+		case TCP_V4_FLOW:
+		case UDP_V4_FLOW:
+		case SCTP_V4_FLOW:
+			if (cmd->data & RXH_IP_SRC)
+				hfld |= IECM_ADV_RSS_HASH_FLD_IPV4_SA;
+			if (cmd->data & RXH_IP_DST)
+				hfld |= IECM_ADV_RSS_HASH_FLD_IPV4_DA;
+			break;
+		case TCP_V6_FLOW:
+		case UDP_V6_FLOW:

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3997

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+		case SCTP_V6_FLOW:
+			if (cmd->data & RXH_IP_SRC)
+				hfld |= IECM_ADV_RSS_HASH_FLD_IPV6_SA;
+			if (cmd->data & RXH_IP_DST)
+				hfld |= IECM_ADV_RSS_HASH_FLD_IPV6_DA;
+			break;
+		default:
+			break;
+		}
+	}
	if (!condition)
		goto here;

as well (-1 indent).

Quoted 112 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +112 -0
+
+	if (cmd->data & RXH_L4_B_0_1 || cmd->data & RXH_L4_B_2_3) {
+		switch (cmd->flow_type) {
+		case TCP_V4_FLOW:
+		case TCP_V6_FLOW:
+			if (cmd->data & RXH_L4_B_0_1)
+				hfld |= IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT;
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |= IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT;
+			break;
+		case UDP_V4_FLOW:
+		case UDP_V6_FLOW:
+			if (cmd->data & RXH_L4_B_0_1)
+				hfld |= IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT;
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |= IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT;
+			break;
+		case SCTP_V4_FLOW:
+		case SCTP_V6_FLOW:
+			if (cmd->data & RXH_L4_B_0_1)
+				hfld |= IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT;
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |= IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return hfld;
+}
+
+/**
+ * iecm_set_adv_rss_hash_opt - Enable/Disable flow types for RSS hash
+ * @vport: vport structure
+ * @cmd: ethtool rxnfc command
+ *
+ * Returns Success if the flow input set is supported.
+ */
+int
+iecm_set_adv_rss_hash_opt(struct iecm_vport *vport, struct ethtool_rxnfc *cmd)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss, *rss_new;
+	u64 hash_flds;
+	u32 hdrs;
+	int err;
+
+	if (adapter->state != __IECM_UP)
+		return -EIO;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS, VIRTCHNL2_CAP_ADV_RSS))
+		return -EOPNOTSUPP;
+
+	hdrs = iecm_adv_rss_parse_hdrs(cmd);
+	if (hdrs == IECM_ADV_RSS_FLOW_SEG_HDR_NONE)
+		return -EINVAL;
+
+	hash_flds = iecm_adv_rss_parse_hash_flds(cmd);
+	if (hash_flds == IECM_ADV_RSS_HASH_INVALID)
+		return -EINVAL;
+
+	rss_new = kzalloc(sizeof(*rss_new), GFP_KERNEL);
+	if (!rss_new)
+		return -ENOMEM;
+
+	/* Since this can fail, do it now to avoid dirtying the list, we'll
+	 * copy it from rss_new if it turns out we're updating an existing
+	 * filter instead of adding a new one.
+	 */
+	if (iecm_fill_adv_rss_cfg_msg(&rss_new->cfg_msg, hdrs, hash_flds)) {
+		kfree(rss_new);
+		return -EINVAL;
+	}
+
+	iecm_dump_adv_rss_cfg_info(vport, hdrs, hash_flds,
+				   "Input set change for", "is pending");
+
+	spin_lock_bh(&adapter->adv_rss_list_lock);
+	rss = iecm_find_adv_rss_cfg_by_hdrs(vport, hdrs);
+	if (rss) {
+		if (rss->hash_flds != hash_flds) {
+			rss->remove = false;
+			memcpy(&rss->cfg_msg, &rss_new->cfg_msg,
+			       sizeof(rss_new->cfg_msg));
+			kfree(rss_new);
+		} else {
+			kfree(rss_new);
+			spin_unlock_bh(&adapter->adv_rss_list_lock);
+			return -EEXIST;
+		}
+	} else {
+		rss = rss_new;
+		rss->packet_hdrs = hdrs;
+		list_add_tail(&rss->list, &adapter->config_data.adv_rss_list);
+	}
+	rss->add = true;
+	rss->hash_flds = hash_flds;
+	spin_unlock_bh(&adapter->adv_rss_list_lock);
+
+	err = iecm_send_add_del_adv_rss_cfg_msg(vport, true);
+	if (err) {
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		/* We have to find it again to make sure another thread hasn't
+		 * already deleted and kfreed it.
+		 */
+		rss = iecm_find_adv_rss_cfg_by_hdrs(vport, hdrs);
+		if (rss) {
+			list_del(&rss->list);
+			kfree(rss);
+		}
+		spin_unlock_bh(&adapter->adv_rss_list_lock);

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 4119

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+	}
+
+	if (!err)
+		iecm_dump_adv_rss_cfg_info(vport, hdrs, hash_flds,
+					   "Input set change for",
+					   "successful");
+	else
+		iecm_dump_adv_rss_cfg_info(vport, hdrs, hash_flds,
+					   "Failed to change the input set for",
+					   NULL);

It doesn't really look good. You could pass err or just bool success to the function itself and print those there.

Quoted 241 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +63 -0
+
+	return err;
+}
+
+/**
+ * iecm_get_adv_rss_hash_opt - Retrieve hash fields for a given flow-type
+ * @vport: vport structure
+ * @cmd: ethtool rxnfc command
+ *
+ * Returns Success if the flow input set is supported.
+ */
+int
+iecm_get_adv_rss_hash_opt(struct iecm_vport *vport, struct ethtool_rxnfc *cmd)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss;
+	u64 hash_flds;
+	u32 hdrs;
+
+	if (adapter->state != __IECM_UP)
+		return -EIO;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS, VIRTCHNL2_CAP_ADV_RSS))
+		return -EOPNOTSUPP;
+
+	cmd->data = 0;
+
+	hdrs = iecm_adv_rss_parse_hdrs(cmd);
+	if (hdrs == IECM_ADV_RSS_FLOW_SEG_HDR_NONE)
+		return -EINVAL;
+
+	spin_lock_bh(&adapter->adv_rss_list_lock);
+	rss = iecm_find_adv_rss_cfg_by_hdrs(vport, hdrs);
+	if (rss)
+		hash_flds = rss->hash_flds;
+	else
+		hash_flds = IECM_ADV_RSS_HASH_INVALID;
+	spin_unlock_bh(&adapter->adv_rss_list_lock);
+
+	if (hash_flds == IECM_ADV_RSS_HASH_INVALID)
+		return -EINVAL;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_SA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_SA))
+		cmd->data |= (u64)RXH_IP_SRC;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_DA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_DA))
+		cmd->data |= (u64)RXH_IP_DST;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT))
+		cmd->data |= (u64)RXH_L4_B_0_1;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT))
+		cmd->data |= (u64)RXH_L4_B_2_3;
+
+	return 0;
+}
+
 /**
  * iecm_pkt_udp_no_pay_len - the length of UDP packet without payload
  * @fltr: Flow Director filter data structure
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +71 -0
index 94af45c36866..c05baf12515c 100644
@@ -2799,6 +2799,77 @@ int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)
 	return err;
 }
 
+/**
+ * iecm_send_add_del_adv_rss_cfg_msg: Send add/del RSS configuration message
+ * @vport: vport structure
+ * @add: True to add, false to delete RSS configuration
+ *
+ * Request the CP/PF to add/del RSS configuration as specified by the user via
+ * ethtool
+ *
+ * Return 0 on success, negative on failure
+ **/
+int iecm_send_add_del_adv_rss_cfg_msg(struct iecm_vport *vport, bool add)
+{
+	struct iecm_adapter *adapter = vport->adapter;
+	struct virtchnl_rss_cfg *rss_cfg;
+	struct iecm_adv_rss *rss;
+	int len, err = -ENXIO;
+
+	len = sizeof(struct virtchnl_rss_cfg);
+	rss_cfg = kzalloc(len, GFP_KERNEL);
+	if (!rss_cfg)
+		return -ENOMEM;
+
+	while (true) {
+		bool process_rss = false;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter->config_data.adv_rss_list, list) {
+			if (add && rss->add) {
+				/* Only add needs print the RSS information */
+				process_rss = true;
+				rss->add = false;
+				memcpy(rss_cfg, &rss->cfg_msg, len);
+				break;
+			} else if (!add && rss->remove) {
+				process_rss = true;
+				rss->remove = false;
+				memcpy(rss_cfg, &rss->cfg_msg, len);
+				break;
+			}
+		}
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+
+		/* Don't send mailbox message when there are no RSS to add/del */
+		if (!process_rss)
+			break;
+
+		if (add) {
+			err = iecm_send_mb_msg(adapter, VIRTCHNL_OP_ADD_RSS_CFG,
+					       len, (u8 *)rss_cfg);
+			if (err)
+				break;
+
+			err = iecm_wait_for_event(adapter, IECM_VC_ADD_RSS_CFG,
+						  IECM_VC_ADD_RSS_CFG_ERR);
+		} else {
+			err = iecm_send_mb_msg(adapter, VIRTCHNL_OP_DEL_RSS_CFG,
+					       len, (u8 *)rss_cfg);
+			if (err)
+				break;
+
+			err = iecm_min_wait_for_event(adapter, IECM_VC_DEL_RSS_CFG,
+						      IECM_VC_DEL_RSS_CFG_ERR);
+		}
+		if (err)
+			break;
+	}
+
+	kfree(rss_cfg);
+	return err;
+}
+
 /**
  * iecm_send_add_fdir_filter_msg: Send add Flow Director filter message
  * @vport: vport structure
drivers/net/ethernet/intel/include/iecm.h +73 -0
index 0aab41cf982c..c7be8c88f9b3 100644
@@ -432,6 +432,74 @@ struct iecm_channel_config {
 	u8 num_tc;
 };
 
+enum iecm_adv_rss_flow_seg_hdr {
+	IECM_ADV_RSS_FLOW_SEG_HDR_NONE	= 0x00000000,
+	IECM_ADV_RSS_FLOW_SEG_HDR_IPV4	= 0x00000001,
+	IECM_ADV_RSS_FLOW_SEG_HDR_IPV6	= 0x00000002,
+	IECM_ADV_RSS_FLOW_SEG_HDR_TCP	= 0x00000004,
+	IECM_ADV_RSS_FLOW_SEG_HDR_UDP	= 0x00000008,
+	IECM_ADV_RSS_FLOW_SEG_HDR_SCTP	= 0x00000010,
+};
+
+#define IECM_ADV_RSS_FLOW_SEG_HDR_L3		\
+	(IECM_ADV_RSS_FLOW_SEG_HDR_IPV4	|	\
+	 IECM_ADV_RSS_FLOW_SEG_HDR_IPV6)
+
+#define IECM_ADV_RSS_FLOW_SEG_HDR_L4		\
+	(IECM_ADV_RSS_FLOW_SEG_HDR_TCP |	\
+	 IECM_ADV_RSS_FLOW_SEG_HDR_UDP |	\
+	 IECM_ADV_RSS_FLOW_SEG_HDR_SCTP)
+
+enum iecm_adv_rss_flow_field {
+	/* L3 */
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA,
+	/* L4 */
+	IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT,
+
+	/* The total number of enums must not exceed 64 */
+	IECM_ADV_RSS_FLOW_FIELD_IDX_MAX
+};
+
+#define IECM_ADV_RSS_HASH_INVALID	0
+#define IECM_ADV_RSS_HASH_FLD_IPV4_SA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA)
+#define IECM_ADV_RSS_HASH_FLD_IPV6_SA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA)
+#define IECM_ADV_RSS_HASH_FLD_IPV4_DA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA)
+#define IECM_ADV_RSS_HASH_FLD_IPV6_DA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA)
+#define IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT)
+#define IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT)
+#define IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT)
+#define IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT)
+#define IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT)
+#define IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT)
+
+/* bookkeeping of advanced RSS configuration */
+struct iecm_adv_rss {
+	struct list_head list;
+	u32 packet_hdrs;
+	u64 hash_flds;
+	struct virtchnl_rss_cfg cfg_msg;
+	bool remove;	/* RSS filter needs to be deleted */
+	bool add;	/* RSS filter needs to be added */
+};
+
 enum iecm_fdir_flow_type {
 	/* NONE - used for undef/error */
 	IECM_FDIR_FLOW_NONE = 0,
@@ -878,6 +946,11 @@ void iecm_vport_set_hsplit(struct iecm_vport *vport, bool ena);
 void iecm_add_del_ether_addrs(struct iecm_vport *vport, bool add, bool async);
 int iecm_set_promiscuous(struct iecm_adapter *adapter);
 int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add);
+int iecm_send_add_del_adv_rss_cfg_msg(struct iecm_vport *vport, bool add);
+int iecm_set_adv_rss_hash_opt(struct iecm_vport *vport,
+			      struct ethtool_rxnfc *cmd);
+int iecm_get_adv_rss_hash_opt(struct iecm_vport *vport,
+			      struct ethtool_rxnfc *cmd);
 int iecm_send_add_fdir_filter_msg(struct iecm_vport *vport);
 int iecm_send_del_fdir_filter_msg(struct iecm_vport *vport);
 int iecm_get_fdir_fltr_entry(struct iecm_vport *vport,
Signature · 1 line
2.33.0

Thanks,
Al

#75 lore raw

PATCH 18/19 iecm: add advanced rss

Quoted 53 lines

-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 11:54 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; Wang, Haiyue <[email protected]>; intel-wired-lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 18/19] iecm: add advanced rss

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:08 -0800

Quoted 4 lines

From: Haiyue Wang <[email protected]>

Continuing with advanced features this implements what's needed to do advanced rss.

I'm sorry for not mentioned it before, but most of the series' commit messages are poor and would probably get rejected upstream. If they were explaining at least some very basics, it would be better. Even better if there were explanations of some tricky code that happens time to time.

Quoted 4 lines
---
 drivers/net/ethernet/intel/iecm/iecm_lib.c    | 547

++++++++++++++++++

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct

Quoted 10 lines
 .../net/ethernet/intel/iecm/iecm_virtchnl.c   |  71 +++
 drivers/net/ethernet/intel/include/iecm.h     |  73 +++
 3 files changed, 691 insertions(+)
drivers/net/ethernet/intel/iecm/iecm_lib.c +0 -0
index d11413cb438c..baa1e312652a 100644
@@ -1013,6 +1013,52 @@ static void iecm_remove_vlan_filters(struct

iecm_vport *vport)

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport)

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8 -0
 	}
 }
 
+/**
+ * iecm_remove_adv_rss_cfgs - Remove all RSS configuration
+ * @vport: vport structure
+ */
+static void iecm_remove_adv_rss_cfgs(struct iecm_vport *vport) {
+	struct iecm_adapter *adapter = vport->adapter;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_ADV_RSS))

Quoted 14 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1034

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+		return;
+
+	if (!list_empty(&adapter->config_data.adv_rss_list)) {
+		struct iecm_adv_rss *rss;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter-
 config_data.adv_rss_list,
+				    list) {
+			rss->remove = true;
+		}

Redundant braces arond an one-liner.

Maybe will fix.

Quoted 6 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1037

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+		iecm_send_add_del_adv_rss_cfg_msg(vport, false);
+	}

Invert the condition for -1 indent level.

Will fix.

Quoted 253 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_vport_stop(struct iecm_vport

Quoted 28 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +24 -0
+}
+
+/**
+ * iecm_del_all_adv_rss_cfgs - delete all RSS configuration
+ * @vport: vport structure
+ *
+ * This function will loop through the list of RSS configuration and
+deletes
+ * them.
+ **/
+static void iecm_del_all_adv_rss_cfgs(struct iecm_vport *vport) {
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss, *rss_tmp;
+
+	spin_lock_bh(&adapter->adv_rss_list_lock);
+	list_for_each_entry_safe(rss, rss_tmp,
+				 &adapter->config_data.adv_rss_list,
+				 list) {
+		list_del(&rss->list);
+		kfree(rss);
+	}
+	spin_unlock_bh(&adapter->adv_rss_list_lock);
+}
+
 /**
  * iecm_remove_fdir_filters - Remove all Flow Director filters
  * @vport: vport structure
@@ -1099,6 +1145,7 @@ static void iecm_vport_stop(struct iecm_vport

*vport)

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_cloud_filters(struct

Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +1 -0
 		iecm_remove_vlan_filters(vport);
 	}
 
+	iecm_remove_adv_rss_cfgs(vport);
 	iecm_remove_fdir_filters(vport);
 
 	adapter->link_up = false;
@@ -1332,6 +1379,27 @@ static void iecm_restore_cloud_filters(struct

iecm_vport *vport)

Quoted 19 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +15 -0
 	}
 }
 
+/**
+ * iecm_restore_adv_rss_cfgs - Restore all RSS configuration
+ * @vport: vport structure
+ */
+static void iecm_restore_adv_rss_cfgs(struct iecm_vport *vport) {
+	struct iecm_adapter *adapter = vport->adapter;
+
+	if (!list_empty(&adapter->config_data.adv_rss_list)) {
+		struct iecm_adv_rss *rss;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter-
 config_data.adv_rss_list,
+				    list) {
+			rss->add = true;
+		}

...

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+		iecm_send_add_del_adv_rss_cfg_msg(vport, true);
+	}

...

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct

Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+}
+
 /**
  * iecm_restore_fdir_filters - Restore all Flow Director filters
  * @vport: vport structure
@@ -1380,6 +1448,9 @@ static void iecm_restore_features(struct

iecm_vport *vport)

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct iecm_vport *vport)

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +1 -0
 	if (iecm_is_feature_ena(vport, NETIF_F_HW_TC))
 		iecm_restore_cloud_filters(vport);
 
+	if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_ADV_RSS))

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_restore_features(struct iecm_vport *vport)

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+		iecm_restore_adv_rss_cfgs(vport);
+
 	if (iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_FDIR))

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_del_user_cfg_data(struct

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +0 -0
 		iecm_restore_fdir_filters(vport);
 }
@@ -2219,6 +2290,7 @@ static void iecm_del_user_cfg_data(struct

iecm_adapter *adapter)

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device

Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +1 -0
 		if (!adapter->vports[i])
 			continue;
 
+		iecm_del_all_adv_rss_cfgs(adapter->vports[i]);
 		iecm_del_all_fdir_filters(adapter->vports[i]);
 	}
 }
@@ -3633,6 +3705,481 @@ static int iecm_setup_tc(struct net_device

*netdev, enum tc_setup_type type,

Quoted 31 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +28 -0
 	return err;
 }
 
+/**
+ * iecm_fill_adv_rss_ip4_hdr - fill the IPv4 RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields  */ static
+void iecm_fill_adv_rss_ip4_hdr(struct virtchnl_proto_hdr *hdr, u64
+hash_flds) {
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV4);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV4_SA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, SRC);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV4_DA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, DST); }
+
+/**
+ * iecm_fill_adv_rss_ip6_hdr - fill the IPv6 RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields  */ static
+void iecm_fill_adv_rss_ip6_hdr(struct virtchnl_proto_hdr *hdr, u64
+hash_flds) {
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, IPV6);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV6_SA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, SRC);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_IPV6_DA)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, DST); }
+

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+/**
+ * iecm_fill_adv_rss_tcp_hdr - fill the TCP RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields  */ static
+void iecm_fill_adv_rss_tcp_hdr(struct virtchnl_proto_hdr *hdr, u64
+hash_flds) {
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, TCP);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,

SRC_PORT);

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,

DST_PORT); }

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11 -0
+
+/**
+ * iecm_fill_adv_rss_udp_hdr - fill the UDP RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields  */ static
+void iecm_fill_adv_rss_udp_hdr(struct virtchnl_proto_hdr *hdr, u64
+hash_flds) {
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, UDP);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, UDP,

SRC_PORT);

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, UDP,

DST_PORT); }

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +11 -0
+
+/**
+ * iecm_fill_adv_rss_sctp_hdr - fill the SCTP RSS protocol header
+ * @hdr: the virtchnl message protocol header data structure
+ * @hash_flds: the RSS configuration protocol hash fields  */ static
+void iecm_fill_adv_rss_sctp_hdr(struct virtchnl_proto_hdr *hdr, s64
+hash_flds) {
+	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr, SCTP);
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, SCTP,

SRC_PORT);

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 3 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+
+	if (hash_flds & IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, SCTP,

DST_PORT); }

Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8 -0
+
+/**
+ * iecm_fill_adv_rss_cfg_msg - fill the RSS configuration into
+virtchnl message
+ * @rss_cfg: the virtchnl message to be filled with RSS configuration
+setting
+ * @packet_hdrs: the RSS configuration protocol header types
+ * @hash_flds: the RSS configuration protocol hash fields

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+ *
+ * Returns 0 if the RSS configuration virtchnl message is filled
+successfully  */ static int iecm_fill_adv_rss_cfg_msg(struct
+virtchnl_rss_cfg *rss_cfg,
+			  u32 packet_hdrs, u64 hash_flds)
+{
+	struct virtchnl_proto_hdrs *proto_hdrs = &rss_cfg->proto_hdrs;
+	struct virtchnl_proto_hdr *hdr;
+
+	rss_cfg->rss_algorithm =

VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC;

Quoted 61 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +61 -0
+
+	proto_hdrs->tunnel_level = 0;	/* always outer layer */
+
+	hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
+	switch (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_L3) {
+	case IECM_ADV_RSS_FLOW_SEG_HDR_IPV4:
+		iecm_fill_adv_rss_ip4_hdr(hdr, hash_flds);
+		break;
+	case IECM_ADV_RSS_FLOW_SEG_HDR_IPV6:
+		iecm_fill_adv_rss_ip6_hdr(hdr, hash_flds);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++];
+	switch (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_L4) {
+	case IECM_ADV_RSS_FLOW_SEG_HDR_TCP:
+		iecm_fill_adv_rss_tcp_hdr(hdr, hash_flds);
+		break;
+	case IECM_ADV_RSS_FLOW_SEG_HDR_UDP:
+		iecm_fill_adv_rss_udp_hdr(hdr, hash_flds);
+		break;
+	case IECM_ADV_RSS_FLOW_SEG_HDR_SCTP:
+		iecm_fill_adv_rss_sctp_hdr(hdr, hash_flds);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/**
+ * iecm_find_adv_rss_cfg_by_hdrs - find RSS configuration with header
+type
+ * @vport: vport structure
+ * @packet_hdrs: protocol header type to find.
+ *
+ * Returns pointer to advance RSS configuration if found or null  */
+static struct iecm_adv_rss * iecm_find_adv_rss_cfg_by_hdrs(struct
+iecm_vport *vport, u32 packet_hdrs) {
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss;
+
+	list_for_each_entry(rss, &adapter->config_data.adv_rss_list, list)
+		if (rss->packet_hdrs == packet_hdrs)
+			return rss;
+
+	return NULL;
+}
+
+/**
+ * iecm_dump_adv_rss_cfg_info
+ * @vport: vport structure
+ * @packet_hdrs: The protocol headers for RSS configuration
+ * @hash_flds: The protocol hash fields for RSS configuration
+ * @prefix: the prefix string description to dump the RSS
+ * @postfix: the postfix string description to dump the RSS
+ *
+ * Dump the advance RSS configuration  **/ static void
Quoted 9 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3877

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4 -0
+iecm_dump_adv_rss_cfg_info(struct iecm_vport *vport,
+			   u32 packet_hdrs, u64 hash_flds,
+			   const char *prefix, const char *postfix) {
+	static char hash_opt[300];

static places it into BSS. If multiple cores call this function at the same time, it will mess up.
I'd just kzalloc() a buffer and then kfree() it.

Hmm yes this is suspect, will fix.

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8 -0
+	const char *proto;
+
+	if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_TCP)
+		proto = "TCP";
+	else if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_UDP)
+		proto = "UDP";
+	else if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_SCTP)
+		proto = "SCTP";
Quoted 9 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3891

Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6 -0
+	else
+		return;
+
+	memset(hash_opt, 0, sizeof(hash_opt));
+
+	strcat(hash_opt, proto);

Consider using strlcat() please.

Will check.

Quoted 87 lines
Quoted 74 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +74 -0
+	if (packet_hdrs & IECM_ADV_RSS_FLOW_SEG_HDR_IPV4)
+		strcat(hash_opt, "v4 ");
+	else
+		strcat(hash_opt, "v6 ");
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_SA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_SA))
+		strcat(hash_opt, "[IP SA] ");
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_DA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_DA))
+		strcat(hash_opt, "[IP DA] ");
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT))
+		strcat(hash_opt, "[src port] ");
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT))
+		strcat(hash_opt, "[dst port] ");
+
+	if (!prefix)
+		prefix = "";
+
+	if (!postfix)
+		postfix = "";
+
+	dev_info(&vport->adapter->pdev->dev, "%s %s %s\n",
+		 prefix, hash_opt, postfix);
+}
+
+/**
+ * iecm_adv_rss_parse_hdrs - parses headers from RSS hash input
+ * @cmd: ethtool rxnfc command
+ *
+ * This function parses the rxnfc command and returns intended
+ * header types for RSS configuration  */ static u32
+iecm_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) {
+	u32 hdrs = IECM_ADV_RSS_FLOW_SEG_HDR_NONE;
+
+	switch (cmd->flow_type) {
+	case TCP_V4_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_TCP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV4;
+		break;
+	case UDP_V4_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_UDP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV4;
+		break;
+	case SCTP_V4_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_SCTP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV4;
+		break;
+	case TCP_V6_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_TCP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV6;
+		break;
+	case UDP_V6_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_UDP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV6;
+		break;
+	case SCTP_V6_FLOW:
+		hdrs |= IECM_ADV_RSS_FLOW_SEG_HDR_SCTP |
+			IECM_ADV_RSS_FLOW_SEG_HDR_IPV6;
+		break;
+	default:
+		break;
+	}
+
+	return hdrs;
+}
+
+/**
+ * iecm_adv_rss_parse_hash_flds - parses hash fields from RSS hash
+input

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3976

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+ * @cmd: ethtool rxnfc command
+ *
+ * This function parses the rxnfc command and returns intended hash
+fields for
+ * RSS configuration
+ */
+static u64 iecm_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd) {
+	u64 hfld = IECM_ADV_RSS_HASH_INVALID;
+
+	if (cmd->data & RXH_IP_SRC || cmd->data & RXH_IP_DST) {

Braces are actually *needed* around bitops. So,

Quoted 2 lines
	if ((cmd->data & RXH_IP_SRC) || (...)) {

Will fix

Quoted 29 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6 -0
+		switch (cmd->flow_type) {
+		case TCP_V4_FLOW:
+		case UDP_V4_FLOW:
+		case SCTP_V4_FLOW:
+			if (cmd->data & RXH_IP_SRC)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_IPV4_SA;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 3965

Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+			if (cmd->data & RXH_IP_DST)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_IPV4_DA;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 6 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +6 -0
+			break;
+		case TCP_V6_FLOW:
+		case UDP_V6_FLOW:
+		case SCTP_V6_FLOW:
+			if (cmd->data & RXH_IP_SRC)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_IPV6_SA;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 3973

Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+			if (cmd->data & RXH_IP_DST)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_IPV6_DA;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 3840

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5 -0
+			break;
+		default:
+			break;
+		}
+	}
	if (!condition)
		goto here;
Quoted 2 lines

as well (-1 indent).

Will fix.

Quoted 132 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7 -0
+
+	if (cmd->data & RXH_L4_B_0_1 || cmd->data & RXH_L4_B_2_3) {
+		switch (cmd->flow_type) {
+		case TCP_V4_FLOW:
+		case TCP_V6_FLOW:
+			if (cmd->data & RXH_L4_B_0_1)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 3987

Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5 -0
+			break;
+		case UDP_V4_FLOW:
+		case UDP_V6_FLOW:
+			if (cmd->data & RXH_L4_B_0_1)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 3994

Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +5 -0
+			break;
+		case SCTP_V4_FLOW:
+		case SCTP_V6_FLOW:
+			if (cmd->data & RXH_L4_B_0_1)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device · line 4001

Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +2 -0
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |=

IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT;

Quoted 19 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +19 -0
+			break;
+		default:
+			break;
+		}
+	}
+
+	return hfld;
+}
+
+/**
+ * iecm_set_adv_rss_hash_opt - Enable/Disable flow types for RSS hash
+ * @vport: vport structure
+ * @cmd: ethtool rxnfc command
+ *
+ * Returns Success if the flow input set is supported.
+ */
+int
+iecm_set_adv_rss_hash_opt(struct iecm_vport *vport, struct
+ethtool_rxnfc *cmd) {

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss, *rss_new;
+	u64 hash_flds;
+	u32 hdrs;
+	int err;
+
+	if (adapter->state != __IECM_UP)
+		return -EIO;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_ADV_RSS))

Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9 -0
+		return -EOPNOTSUPP;
+
+	hdrs = iecm_adv_rss_parse_hdrs(cmd);
+	if (hdrs == IECM_ADV_RSS_FLOW_SEG_HDR_NONE)
+		return -EINVAL;
+
+	hash_flds = iecm_adv_rss_parse_hash_flds(cmd);
+	if (hash_flds == IECM_ADV_RSS_HASH_INVALID)
+		return -EINVAL;

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+
+	rss_new = kzalloc(sizeof(*rss_new), GFP_KERNEL);
+	if (!rss_new)
+		return -ENOMEM;
+
+	/* Since this can fail, do it now to avoid dirtying the list, we'll
+	 * copy it from rss_new if it turns out we're updating an existing
+	 * filter instead of adding a new one.
+	 */
+	if (iecm_fill_adv_rss_cfg_msg(&rss_new->cfg_msg, hdrs,

hash_flds)) {

Quoted 24 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +24 -0
+		kfree(rss_new);
+		return -EINVAL;
+	}
+
+	iecm_dump_adv_rss_cfg_info(vport, hdrs, hash_flds,
+				   "Input set change for", "is pending");
+
+	spin_lock_bh(&adapter->adv_rss_list_lock);
+	rss = iecm_find_adv_rss_cfg_by_hdrs(vport, hdrs);
+	if (rss) {
+		if (rss->hash_flds != hash_flds) {
+			rss->remove = false;
+			memcpy(&rss->cfg_msg, &rss_new->cfg_msg,
+			       sizeof(rss_new->cfg_msg));
+			kfree(rss_new);
+		} else {
+			kfree(rss_new);
+			spin_unlock_bh(&adapter->adv_rss_list_lock);
+			return -EEXIST;
+		}
+	} else {
+		rss = rss_new;
+		rss->packet_hdrs = hdrs;
+		list_add_tail(&rss->list, &adapter-

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +9 -0
 config_data.adv_rss_list);
+	}
+	rss->add = true;
+	rss->hash_flds = hash_flds;
+	spin_unlock_bh(&adapter->adv_rss_list_lock);
+
+	err = iecm_send_add_del_adv_rss_cfg_msg(vport, true);
+	if (err) {
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		/* We have to find it again to make sure another thread

hasn't

Quoted 7 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +7 -0
+		 * already deleted and kfreed it.
+		 */
+		rss = iecm_find_adv_rss_cfg_by_hdrs(vport, hdrs);
+		if (rss) {
+			list_del(&rss->list);
+			kfree(rss);
+		}

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+	}
+
+	if (!err)
+		iecm_dump_adv_rss_cfg_info(vport, hdrs, hash_flds,
+					   "Input set change for",
+					   "successful");
+	else
+		iecm_dump_adv_rss_cfg_info(vport, hdrs, hash_flds,
+					   "Failed to change the input set

for",

Quoted 5 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 4119

Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_lib.c +1 -0
+					   NULL);

It doesn't really look good. You could pass err or just bool success to the function itself and print those there.

Fair. Will fix.

Quoted 264 lines
Quoted 14 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +14 -0
+
+	return err;
+}
+
+/**
+ * iecm_get_adv_rss_hash_opt - Retrieve hash fields for a given
+flow-type
+ * @vport: vport structure
+ * @cmd: ethtool rxnfc command
+ *
+ * Returns Success if the flow input set is supported.
+ */
+int
+iecm_get_adv_rss_hash_opt(struct iecm_vport *vport, struct

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+ethtool_rxnfc *cmd) {
+	struct iecm_adapter *adapter = vport->adapter;
+	struct iecm_adv_rss *rss;
+	u64 hash_flds;
+	u32 hdrs;
+
+	if (adapter->state != __IECM_UP)
+		return -EIO;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_ADV_RSS))

Quoted 32 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +32 -0
+		return -EOPNOTSUPP;
+
+	cmd->data = 0;
+
+	hdrs = iecm_adv_rss_parse_hdrs(cmd);
+	if (hdrs == IECM_ADV_RSS_FLOW_SEG_HDR_NONE)
+		return -EINVAL;
+
+	spin_lock_bh(&adapter->adv_rss_list_lock);
+	rss = iecm_find_adv_rss_cfg_by_hdrs(vport, hdrs);
+	if (rss)
+		hash_flds = rss->hash_flds;
+	else
+		hash_flds = IECM_ADV_RSS_HASH_INVALID;
+	spin_unlock_bh(&adapter->adv_rss_list_lock);
+
+	if (hash_flds == IECM_ADV_RSS_HASH_INVALID)
+		return -EINVAL;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_SA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_SA))
+		cmd->data |= (u64)RXH_IP_SRC;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_IPV4_DA |
+			 IECM_ADV_RSS_HASH_FLD_IPV6_DA))
+		cmd->data |= (u64)RXH_IP_DST;
+
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT))
+		cmd->data |= (u64)RXH_L4_B_0_1;
+

drivers/net/ethernet/intel/iecm/iecm_lib.c static int iecm_setup_tc(struct net_device *netdev, enum tc_setup_type type,

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8 -0
+	if (hash_flds & (IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT |
+			 IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT))
+		cmd->data |= (u64)RXH_L4_B_2_3;
+
+	return 0;
+}
+
 /**
  * iecm_pkt_udp_no_pay_len - the length of UDP packet without

payload

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int

Quoted 7 lines

* @fltr: Flow Director filter data structure diff --git
a/drivers/net/ethernet/intel/iecm/iecm_virtchnl.c b/drivers/net/ethernet/intel/iecm/iecm_virtchnl.c index 94af45c36866..c05baf12515c 100644

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +0 -0
@@ -2799,6 +2799,77 @@ int

iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int · line 2803

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +2 -0
 	return err;
 }
 
+/**
+ * iecm_send_add_del_adv_rss_cfg_msg: Send add/del RSS

configuration

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +10 -0
+message
+ * @vport: vport structure
+ * @add: True to add, false to delete RSS configuration
+ *
+ * Request the CP/PF to add/del RSS configuration as specified by the
+user via
+ * ethtool
+ *
+ * Return 0 on success, negative on failure  **/ int
+iecm_send_add_del_adv_rss_cfg_msg(struct iecm_vport *vport, bool

add)

Quoted 9 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +9 -0
+{
+	struct iecm_adapter *adapter = vport->adapter;
+	struct virtchnl_rss_cfg *rss_cfg;
+	struct iecm_adv_rss *rss;
+	int len, err = -ENXIO;
+
+	len = sizeof(struct virtchnl_rss_cfg);
+	rss_cfg = kzalloc(len, GFP_KERNEL);
+	if (!rss_cfg)

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +9 -0
+		return -ENOMEM;
+
+	while (true) {
+		bool process_rss = false;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter-
 config_data.adv_rss_list, list) {
+			if (add && rss->add) {
+				/* Only add needs print the RSS information

*/

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +4 -0
+				process_rss = true;
+				rss->add = false;
+				memcpy(rss_cfg, &rss->cfg_msg, len);
+				break;

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

Quoted 10 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +10 -0
+			} else if (!add && rss->remove) {
+				process_rss = true;
+				rss->remove = false;
+				memcpy(rss_cfg, &rss->cfg_msg, len);
+				break;
+			}
+		}
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+
+		/* Don't send mailbox message when there are no RSS to

add/del */

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +5 -0
+		if (!process_rss)
+			break;
+
+		if (add) {
+			err = iecm_send_mb_msg(adapter,

VIRTCHNL_OP_ADD_RSS_CFG,

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +5 -0
+					       len, (u8 *)rss_cfg);
+			if (err)
+				break;
+
+			err = iecm_wait_for_event(adapter,

IECM_VC_ADD_RSS_CFG,

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int · line 2857

Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +1 -0
+

IECM_VC_ADD_RSS_CFG_ERR);

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int · line 2859

Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +2 -0
+		} else {
+			err = iecm_send_mb_msg(adapter,

VIRTCHNL_OP_DEL_RSS_CFG,

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int iecm_send_add_del_cloud_filter_msg(struct iecm_vport *vport, bool add)

Quoted 5 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +5 -0
+					       len, (u8 *)rss_cfg);
+			if (err)
+				break;
+
+			err = iecm_min_wait_for_event(adapter,

IECM_VC_DEL_RSS_CFG,

drivers/net/ethernet/intel/iecm/iecm_virtchnl.c int · line 2865

Quoted 1 line
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +1 -0
+

IECM_VC_DEL_RSS_CFG_ERR);

Quoted 94 lines
drivers/net/ethernet/intel/iecm/iecm_virtchnl.c +9 -0
+		}
+		if (err)
+			break;
+	}
+
+	kfree(rss_cfg);
+	return err;
+}
+
 /**
  * iecm_send_add_fdir_filter_msg: Send add Flow Director filter message
  * @vport: vport structure
drivers/net/ethernet/intel/include/iecm.h +67 -0
index 0aab41cf982c..c7be8c88f9b3 100644
@@ -432,6 +432,74 @@ struct iecm_channel_config {
 	u8 num_tc;
 };
 
+enum iecm_adv_rss_flow_seg_hdr {
+	IECM_ADV_RSS_FLOW_SEG_HDR_NONE	= 0x00000000,
+	IECM_ADV_RSS_FLOW_SEG_HDR_IPV4	= 0x00000001,
+	IECM_ADV_RSS_FLOW_SEG_HDR_IPV6	= 0x00000002,
+	IECM_ADV_RSS_FLOW_SEG_HDR_TCP	= 0x00000004,
+	IECM_ADV_RSS_FLOW_SEG_HDR_UDP	= 0x00000008,
+	IECM_ADV_RSS_FLOW_SEG_HDR_SCTP	= 0x00000010,
+};
+
+#define IECM_ADV_RSS_FLOW_SEG_HDR_L3		\
+	(IECM_ADV_RSS_FLOW_SEG_HDR_IPV4	|	\
+	 IECM_ADV_RSS_FLOW_SEG_HDR_IPV6)
+
+#define IECM_ADV_RSS_FLOW_SEG_HDR_L4		\
+	(IECM_ADV_RSS_FLOW_SEG_HDR_TCP |	\
+	 IECM_ADV_RSS_FLOW_SEG_HDR_UDP |	\
+	 IECM_ADV_RSS_FLOW_SEG_HDR_SCTP)
+
+enum iecm_adv_rss_flow_field {
+	/* L3 */
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA,
+	/* L4 */
+	IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT,
+	IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT,
+
+	/* The total number of enums must not exceed 64 */
+	IECM_ADV_RSS_FLOW_FIELD_IDX_MAX
+};
+
+#define IECM_ADV_RSS_HASH_INVALID	0
+#define IECM_ADV_RSS_HASH_FLD_IPV4_SA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA)
+#define IECM_ADV_RSS_HASH_FLD_IPV6_SA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA)
+#define IECM_ADV_RSS_HASH_FLD_IPV4_DA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA)
+#define IECM_ADV_RSS_HASH_FLD_IPV6_DA	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA)
+#define IECM_ADV_RSS_HASH_FLD_TCP_SRC_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT)
+#define IECM_ADV_RSS_HASH_FLD_TCP_DST_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT)
+#define IECM_ADV_RSS_HASH_FLD_UDP_SRC_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT)
+#define IECM_ADV_RSS_HASH_FLD_UDP_DST_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT)
+#define IECM_ADV_RSS_HASH_FLD_SCTP_SRC_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT)
+#define IECM_ADV_RSS_HASH_FLD_SCTP_DST_PORT	\
+	BIT_ULL(IECM_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT)
+
+/* bookkeeping of advanced RSS configuration */ struct iecm_adv_rss {
+	struct list_head list;
+	u32 packet_hdrs;
+	u64 hash_flds;
+	struct virtchnl_rss_cfg cfg_msg;
+	bool remove;	/* RSS filter needs to be deleted */
+	bool add;	/* RSS filter needs to be added */
+};
+
 enum iecm_fdir_flow_type {
 	/* NONE - used for undef/error */
 	IECM_FDIR_FLOW_NONE = 0,
@@ -878,6 +946,11 @@ void iecm_vport_set_hsplit(struct iecm_vport
 *vport, bool ena);  void iecm_add_del_ether_addrs(struct iecm_vport
 *vport, bool add, bool async);  int iecm_set_promiscuous(struct
Quoted 1 line

iecm_adapter *adapter); int

iecm_send_add_del_cloud_filter_msg(struct

Quoted 2 lines

iecm_vport *vport, bool add);
+int iecm_send_add_del_adv_rss_cfg_msg(struct iecm_vport *vport,

bool

Quoted 9 lines
drivers/net/ethernet/intel/include/iecm.h +4 -0
+add); int iecm_set_adv_rss_hash_opt(struct iecm_vport *vport,
+			      struct ethtool_rxnfc *cmd);
+int iecm_get_adv_rss_hash_opt(struct iecm_vport *vport,
+			      struct ethtool_rxnfc *cmd);
 int iecm_send_add_fdir_filter_msg(struct iecm_vport *vport);  int

iecm_send_del_fdir_filter_msg(struct iecm_vport *vport); int iecm_get_fdir_fltr_entry(struct iecm_vport *vport, --
2.33.0

Thanks,
Al

#76 lore raw

PATCH 18/19 iecm: add advanced rss

Quoted 16 lines · Alan
Quoted 16 lines

-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 11:54 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; Wang, Haiyue <[email protected]>; intel-wired-lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 18/19] iecm: add advanced rss

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:08 -0800

Quoted 2 lines

From: Haiyue Wang <[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Continuing with advanced features this implements what's needed to do advanced rss.

I'm sorry for not mentioned it before, but most of the series' commit messages are poor and would probably get rejected upstream. If they were explaining at least some very basics, it would be better. Even better if there were explanations of some tricky code that happens time to time.

I agree this should be improved. I don't know if this would be rejected upstream, but in the future when looking at the commit history it would just be more convenient for us and future readers if the description would have more content in it.

Quoted 44 lines
Quoted 29 lines
Quoted 5 lines
---
 drivers/net/ethernet/intel/iecm/iecm_lib.c    | 547

++++++++++++++++++

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct

Quoted 10 lines
 .../net/ethernet/intel/iecm/iecm_virtchnl.c   |  71 +++
 drivers/net/ethernet/intel/include/iecm.h     |  73 +++
 3 files changed, 691 insertions(+)
drivers/net/ethernet/intel/iecm/iecm_lib.c +0 -0
index d11413cb438c..baa1e312652a 100644
@@ -1013,6 +1013,52 @@ static void iecm_remove_vlan_filters(struct

iecm_vport *vport)

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport)

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8 -0
 	}
 }
 
+/**
+ * iecm_remove_adv_rss_cfgs - Remove all RSS configuration
+ * @vport: vport structure
+ */
+static void iecm_remove_adv_rss_cfgs(struct iecm_vport *vport) {
+	struct iecm_adapter *adapter = vport->adapter;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_ADV_RSS))

Quoted 14 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1034

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+		return;
+
+	if (!list_empty(&adapter->config_data.adv_rss_list)) {
+		struct iecm_adv_rss *rss;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter-
 config_data.adv_rss_list,
+				    list) {
+			rss->remove = true;
+		}

Redundant braces arond an one-liner.

Quoted 1 line

Maybe will fix.

? :D this one-liner is not even spread onto multiple lines, right? So why 'maybe' ?

Quoted 10 lines
Quoted 7 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1037

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+		iecm_send_add_del_adv_rss_cfg_msg(vport, false);
+	}

Invert the condition for -1 indent level.

Will fix.

#77 lore raw

PATCH 18/19 iecm: add advanced rss

In reply to Brady

From: Alan Brady <[email protected]>

From: Alan Brady <[email protected]>
Date: Thu, 3 Feb 2022 03:55:57 +0100

Quoted 68 lines
Quoted 53 lines

-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 11:54 AM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; Wang, Haiyue <[email protected]>; intel-wired-lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 18/19] iecm: add advanced rss

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:08 -0800

Quoted 4 lines

From: Haiyue Wang <[email protected]>

Continuing with advanced features this implements what's needed to do advanced rss.

I'm sorry for not mentioned it before, but most of the series' commit messages are poor and would probably get rejected upstream. If they were explaining at least some very basics, it would be better. Even better if there were explanations of some tricky code that happens time to time.

Quoted 4 lines
---
 drivers/net/ethernet/intel/iecm/iecm_lib.c    | 547

++++++++++++++++++

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct

Quoted 10 lines
 .../net/ethernet/intel/iecm/iecm_virtchnl.c   |  71 +++
 drivers/net/ethernet/intel/include/iecm.h     |  73 +++
 3 files changed, 691 insertions(+)
drivers/net/ethernet/intel/iecm/iecm_lib.c +0 -0
index d11413cb438c..baa1e312652a 100644
@@ -1013,6 +1013,52 @@ static void iecm_remove_vlan_filters(struct

iecm_vport *vport)

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport)

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +8 -0
 	}
 }
 
+/**
+ * iecm_remove_adv_rss_cfgs - Remove all RSS configuration
+ * @vport: vport structure
+ */
+static void iecm_remove_adv_rss_cfgs(struct iecm_vport *vport) {
+	struct iecm_adapter *adapter = vport->adapter;
+
+	if (!iecm_is_cap_ena(adapter, IECM_OTHER_CAPS,

VIRTCHNL2_CAP_ADV_RSS))

Quoted 14 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1034

Quoted 11 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +10 -0
+		return;
+
+	if (!list_empty(&adapter->config_data.adv_rss_list)) {
+		struct iecm_adv_rss *rss;
+
+		spin_lock_bh(&adapter->adv_rss_list_lock);
+		list_for_each_entry(rss, &adapter-
 config_data.adv_rss_list,
+				    list) {
+			rss->remove = true;
+		}

Redundant braces arond an one-liner.

Quoted 1 line

Maybe will fix.

It's a pure error here.

Quoted 8 lines
Quoted 7 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1037

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +3 -0
+		spin_unlock_bh(&adapter->adv_rss_list_lock);
+		iecm_send_add_del_adv_rss_cfg_msg(vport, false);
+	}

Invert the condition for -1 indent level.

Quoted 6 lines

Will fix.

Quoted 4 lines

drivers/net/ethernet/intel/iecm/iecm_lib.c static void iecm_remove_vlan_filters(struct iecm_vport *vport) · line 1041

Quoted 4 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +4 -0
+}
+
+/**
+ * iecm_del_all_adv_rss_cfgs - delete all RSS configuration

--- 8< ---

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
drivers/net/ethernet/intel/iecm/iecm_lib.c +0 -1
--

2.33.0

Thanks,
Al

Al

author
#78 lore raw

PATCH 19/19 idpf: introduce idpf driver

In reply to Alan Brady

This adds the idpf driver which uses the iecm module to provide common functionality. Device specific behavior and registers are defined here and handed off to iecm which takes over the rest of the flow.

---
 .../device_drivers/ethernet/intel/idpf.rst    |  47 ++++++
 drivers/net/ethernet/intel/Kconfig            |  16 ++
 drivers/net/ethernet/intel/Makefile           |   1 +
 drivers/net/ethernet/intel/idpf/Makefile      |  15 ++
 drivers/net/ethernet/intel/idpf/idpf_dev.h    |  17 +++
 drivers/net/ethernet/intel/idpf/idpf_devids.h |  10 ++
 drivers/net/ethernet/intel/idpf/idpf_main.c   | 140 ++++++++++++++++++
 drivers/net/ethernet/intel/idpf/idpf_reg.c    | 130 ++++++++++++++++
 .../ethernet/intel/include/iecm_lan_pf_regs.h | 131 ++++++++++++++++
 9 files changed, 507 insertions(+)
 create mode 100644 Documentation/networking/device_drivers/ethernet/intel/idpf.rst
 create mode 100644 drivers/net/ethernet/intel/idpf/Makefile
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_reg.c
 create mode 100644 drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +47 -0
new file mode 100644
index 000000000000..973fa9613428
@@ -0,0 +1,47 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==================================================================
+Linux Base Driver for the Intel(R) Smart Network Adapter Family Series
+==================================================================
+
+Intel idpf Linux driver.
+Copyright(c) 2020 Intel Corporation.
+
+Contents
+========
+
+- Enabling the driver
+- Support
+
+The driver in this release supports Intel's Smart Network Adapter Family Series
+of products. For more information, visit Intel's support page at
+https://support.intel.com.
+
+Enabling the driver
+===================
+The driver is enabled via the standard kernel configuration system,
+using the make command::
+
+  make oldconfig/menuconfig/etc.
+
+The driver is located in the menu structure at:
+
+  -> Device Drivers
+    -> Network device support (NETDEVICES [=y])
+      -> Ethernet driver support
+        -> Intel devices
+          -> Intel(R) Smart Network Adapter Family Series Support
+
+Support
+=======
+For general information, go to the Intel support website at:
+
+https://www.intel.com/support/
+
+or the Intel Wired Networking project hosted by Sourceforge at:
+
+https://sourceforge.net/projects/e1000
+
+If an issue is identified with the released source code on a supported kernel
+with a supported adapter, email the specific information related to the issue
+to e1000-devel at lists.sf.net.
drivers/net/ethernet/intel/Kconfig +16 -0
index 754dc7677ad5..93c8883c22ad 100644
@@ -387,4 +387,20 @@ config IECM
       To compile this as a module, choose M here. The module will be called
       iecm.
 
+config IDPF
+	tristate "Intel(R) Data Plane Function Support"
+	default n
+	depends on IECM
+	help
+	  For more information on how to identify your adapter, go
+	  to the Adapter & Driver ID Guide that can be located at:
+
+	  <http://support.intel.com>
+
+	  More specific information on configuring the driver is in
+	  <file:Documentation/networking/device_drivers/ethernet/intel/idpf.rst>.
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called idpf.
+
 endif # NET_VENDOR_INTEL
drivers/net/ethernet/intel/Makefile +1 -0
index c9eba9cc5087..3786c2269f3d 100644
@@ -17,3 +17,4 @@ obj-$(CONFIG_IAVF) += iavf/
 obj-$(CONFIG_FM10K) += fm10k/
 obj-$(CONFIG_ICE) += ice/
 obj-$(CONFIG_IECM) += iecm/
+obj-$(CONFIG_IDPF) += idpf/
drivers/net/ethernet/intel/idpf/Makefile new file +15 -0
new file mode 100644
index 000000000000..85846620bc9f
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) 2019 Intel Corporation
+
+#
+# Makefile for the Intel(R) Data Plane Function Linux Driver
+#
+
+obj-$(CONFIG_IDPF) += idpf.o
+
+ccflags-y += -I$(srctree)/drivers/net/ethernet/intel/include \
+			 -I$(srctree)/include/linux/avf
+
+idpf-y := \
+	idpf_main.o \
+	idpf_reg.o
drivers/net/ethernet/intel/idpf/idpf_dev.h new file +17 -0
new file mode 100644
index 000000000000..dc146161f884
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2019 Intel Corporation */
+
+#ifndef _IDPF_DEV_H_
+#define _IDPF_DEV_H_
+
+#include "iecm.h"
+
+int idpf_intr_reg_init(struct iecm_vport *vport);
+void idpf_mb_intr_reg_init(struct iecm_adapter *adapter);
+void idpf_reset_reg_init(struct iecm_reset_reg *reset_reg);
+void idpf_trigger_reset(struct iecm_adapter *adapter,
+			enum iecm_flags trig_cause);
+void idpf_vportq_reg_init(struct iecm_vport *vport);
+void idpf_ctlq_reg_init(struct iecm_ctlq_create_info *cq);
+
+#endif /* _IDPF_DEV_H_ */
drivers/net/ethernet/intel/idpf/idpf_devids.h new file +10 -0
new file mode 100644
index 000000000000..7bf8eb64b76a
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2019 Intel Corporation */
+
+#ifndef _IDPF_DEVIDS_H_
+#define _IDPF_DEVIDS_H_
+
+/* Device IDs */
+#define IDPF_DEV_ID_PF			0x1452
+
+#endif /* _IDPF_DEVIDS_H_ */
drivers/net/ethernet/intel/idpf/idpf_main.c new file +140 -0

140 lines not on this page · raw message

drivers/net/ethernet/intel/idpf/idpf_reg.c new file +130 -0

130 lines not on this page · raw message

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
2.33.0
#79 lore raw

PATCH 19/19 idpf: introduce idpf driver

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:09 -0800

Quoted 3 lines

This adds the idpf driver which uses the iecm module to provide common functionality. Device specific behavior and registers are defined here and handed off to iecm which takes over the rest of the flow.

Ok I missed that before, so I say it now.
Multi-function networking devices (Ethernet, SFs, VF representors, RDMA, storage offload etc.) nowadays kinda *must* be based on top of auxiliary bus. Otherwise, maintaining of hundreds a direct call with recursive dependencies between modules and stuff will become a burden.
All of the mentioned functionality will be added to the driver(s), that's a fact, and as these are new drivers, it's way better to start off the right way now than to bug your mind on how to refactor this later.

Quoted 194 lines
---
 .../device_drivers/ethernet/intel/idpf.rst    |  47 ++++++
 drivers/net/ethernet/intel/Kconfig            |  16 ++
 drivers/net/ethernet/intel/Makefile           |   1 +
 drivers/net/ethernet/intel/idpf/Makefile      |  15 ++
 drivers/net/ethernet/intel/idpf/idpf_dev.h    |  17 +++
 drivers/net/ethernet/intel/idpf/idpf_devids.h |  10 ++
 drivers/net/ethernet/intel/idpf/idpf_main.c   | 140 ++++++++++++++++++
 drivers/net/ethernet/intel/idpf/idpf_reg.c    | 130 ++++++++++++++++
 .../ethernet/intel/include/iecm_lan_pf_regs.h | 131 ++++++++++++++++
 9 files changed, 507 insertions(+)
 create mode 100644 Documentation/networking/device_drivers/ethernet/intel/idpf.rst
 create mode 100644 drivers/net/ethernet/intel/idpf/Makefile
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_reg.c
 create mode 100644 drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +47 -0
new file mode 100644
index 000000000000..973fa9613428
@@ -0,0 +1,47 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==================================================================
+Linux Base Driver for the Intel(R) Smart Network Adapter Family Series
+==================================================================
+
+Intel idpf Linux driver.
+Copyright(c) 2020 Intel Corporation.
+
+Contents
+========
+
+- Enabling the driver
+- Support
+
+The driver in this release supports Intel's Smart Network Adapter Family Series
+of products. For more information, visit Intel's support page at
+https://support.intel.com.
+
+Enabling the driver
+===================
+The driver is enabled via the standard kernel configuration system,
+using the make command::
+
+  make oldconfig/menuconfig/etc.
+
+The driver is located in the menu structure at:
+
+  -> Device Drivers
+    -> Network device support (NETDEVICES [=y])
+      -> Ethernet driver support
+        -> Intel devices
+          -> Intel(R) Smart Network Adapter Family Series Support
+
+Support
+=======
+For general information, go to the Intel support website at:
+
+https://www.intel.com/support/
+
+or the Intel Wired Networking project hosted by Sourceforge at:
+
+https://sourceforge.net/projects/e1000
+
+If an issue is identified with the released source code on a supported kernel
+with a supported adapter, email the specific information related to the issue
+to e1000-devel at lists.sf.net.
drivers/net/ethernet/intel/Kconfig +16 -0
index 754dc7677ad5..93c8883c22ad 100644
@@ -387,4 +387,20 @@ config IECM
       To compile this as a module, choose M here. The module will be called
       iecm.
 
+config IDPF
+	tristate "Intel(R) Data Plane Function Support"
+	default n
+	depends on IECM
+	help
+	  For more information on how to identify your adapter, go
+	  to the Adapter & Driver ID Guide that can be located at:
+
+	  <http://support.intel.com>
+
+	  More specific information on configuring the driver is in
+	  <file:Documentation/networking/device_drivers/ethernet/intel/idpf.rst>.
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called idpf.
+
 endif # NET_VENDOR_INTEL
drivers/net/ethernet/intel/Makefile +1 -0
index c9eba9cc5087..3786c2269f3d 100644
@@ -17,3 +17,4 @@ obj-$(CONFIG_IAVF) += iavf/
 obj-$(CONFIG_FM10K) += fm10k/
 obj-$(CONFIG_ICE) += ice/
 obj-$(CONFIG_IECM) += iecm/
+obj-$(CONFIG_IDPF) += idpf/
drivers/net/ethernet/intel/idpf/Makefile new file +15 -0
new file mode 100644
index 000000000000..85846620bc9f
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) 2019 Intel Corporation
+
+#
+# Makefile for the Intel(R) Data Plane Function Linux Driver
+#
+
+obj-$(CONFIG_IDPF) += idpf.o
+
+ccflags-y += -I$(srctree)/drivers/net/ethernet/intel/include \
+			 -I$(srctree)/include/linux/avf
+
+idpf-y := \
+	idpf_main.o \
+	idpf_reg.o
drivers/net/ethernet/intel/idpf/idpf_dev.h new file +17 -0
new file mode 100644
index 000000000000..dc146161f884
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2019 Intel Corporation */
+
+#ifndef _IDPF_DEV_H_
+#define _IDPF_DEV_H_
+
+#include "iecm.h"
+
+int idpf_intr_reg_init(struct iecm_vport *vport);
+void idpf_mb_intr_reg_init(struct iecm_adapter *adapter);
+void idpf_reset_reg_init(struct iecm_reset_reg *reset_reg);
+void idpf_trigger_reset(struct iecm_adapter *adapter,
+			enum iecm_flags trig_cause);
+void idpf_vportq_reg_init(struct iecm_vport *vport);
+void idpf_ctlq_reg_init(struct iecm_ctlq_create_info *cq);
+
+#endif /* _IDPF_DEV_H_ */
drivers/net/ethernet/intel/idpf/idpf_devids.h new file +10 -0
new file mode 100644
index 000000000000..7bf8eb64b76a
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2019 Intel Corporation */
+
+#ifndef _IDPF_DEVIDS_H_
+#define _IDPF_DEVIDS_H_
+
+/* Device IDs */
+#define IDPF_DEV_ID_PF			0x1452
+
+#endif /* _IDPF_DEVIDS_H_ */
drivers/net/ethernet/intel/idpf/idpf_main.c new file +16 -0
new file mode 100644
index 000000000000..da5e668beabf
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2019 Intel Corporation */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "idpf_dev.h"
+#include "idpf_devids.h"
+
+#define DRV_SUMMARY	"Intel(R) Data Plane Function Linux Driver"
+static const char idpf_driver_string[] = DRV_SUMMARY;
+static const char idpf_copyright[] = "Copyright (c) 2020, Intel Corporation.";
+
+MODULE_DESCRIPTION(DRV_SUMMARY);
+MODULE_LICENSE("GPL");
+
+/**

drivers/net/ethernet/intel/idpf/idpf_main.c line 26

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +10 -0
+ * idpf_reg_ops_init - Initialize register API function pointers
+ * @adapter: Driver specific private structure
+ */
+static void idpf_reg_ops_init(struct iecm_adapter *adapter)
+{
+	adapter->dev_ops.reg_ops.ctlq_reg_init = idpf_ctlq_reg_init;
+	adapter->dev_ops.reg_ops.intr_reg_init = idpf_intr_reg_init;
+	adapter->dev_ops.reg_ops.mb_intr_reg_init = idpf_mb_intr_reg_init;
+	adapter->dev_ops.reg_ops.reset_reg_init = idpf_reset_reg_init;
+	adapter->dev_ops.reg_ops.trigger_reset = idpf_trigger_reset;

Why not define static const reg_ops for idpf and assigning it? Filling plenty of callbacks inside functions are generally discouraged.

drivers/net/ethernet/intel/idpf/idpf_main.c line 37

Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +11 -0
+}
+
+/**
+ * idpf_probe - Device initialization routine
+ * @pdev: PCI device information struct
+ * @ent: entry in idpf_pci_tbl
+ *
+ * Returns 0 on success, negative on failure
+ */
+static int idpf_probe(struct pci_dev *pdev,
+		      const struct pci_device_id __always_unused *ent)

Again, no __always_unused for function parameters.

drivers/net/ethernet/intel/idpf/idpf_main.c line 46

Quoted 9 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +9 -0
+{
+	struct iecm_adapter *adapter = NULL;
+	int err;
+
+	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
+	if (!adapter)
+		return -ENOMEM;
+
+	adapter->dev_ops.reg_ops_init = idpf_reg_ops_init;

Why not just directly assign callbacks here? Callback for filling more callbacks?

Quoted 105 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +94 -0
+	set_bit(__IECM_REQ_TX_SPLITQ, adapter->flags);
+	set_bit(__IECM_REQ_RX_SPLITQ, adapter->flags);
+
+	err = iecm_probe(pdev, ent, adapter);
+	if (err)
+		kfree(adapter);
+
+	return err;
+}
+
+/**
+ * idpf_remove - Device removal routine
+ * @pdev: PCI device information struct
+ */
+static void idpf_remove(struct pci_dev *pdev)
+{
+	struct iecm_adapter *adapter = pci_get_drvdata(pdev);
+
+	if (!adapter)
+		return;
+
+	iecm_remove(pdev);
+	pci_set_drvdata(pdev, NULL);
+	kfree(adapter);
+}
+
+/**
+ * idpf_shutdown - PCI callback for shutting down device
+ * @pdev: PCI device information struct
+ */
+static void idpf_shutdown(struct pci_dev *pdev)
+{
+	idpf_remove(pdev);
+
+	if (system_state == SYSTEM_POWER_OFF)
+		pci_set_power_state(pdev, PCI_D3hot);
+}
+
+/* idpf_pci_tbl - PCI Dev iapf ID Table
+ *
+ * Wildcard entries (PCI_ANY_ID) should come last
+ * Last entry must be all 0s
+ *
+ * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
+ *   Class, Class Mask, private data (not used) }
+ */
+static const struct pci_device_id idpf_pci_tbl[] = {
+	{ PCI_VDEVICE(INTEL, IDPF_DEV_ID_PF), 0 },
+	/* required last entry */
+	{ 0, }
+};
+MODULE_DEVICE_TABLE(pci, idpf_pci_tbl);
+
+static struct pci_driver idpf_driver = {
+	.name = KBUILD_MODNAME,
+	.id_table = idpf_pci_tbl,
+	.probe = idpf_probe,
+	.remove = idpf_remove,
+	.shutdown = idpf_shutdown,
+};
+
+/**
+ * idpf_module_init - Driver registration routine
+ *
+ * idpf_module_init is the first routine called when the driver is
+ * loaded. All it does is register with the PCI subsystem.
+ */
+static int __init idpf_module_init(void)
+{
+	int status;
+
+	pr_info("%s - version %d\n", idpf_driver_string, LINUX_VERSION_CODE);
+	pr_info("%s\n", idpf_copyright);
+
+	status = pci_register_driver(&idpf_driver);
+	if (status)
+		pr_err("failed to register pci driver, err %d\n", status);
+
+	return status;
+}
+module_init(idpf_module_init);
+
+/**
+ * idpf_module_exit - Driver exit cleanup routine
+ *
+ * idpf_module_exit is called just before the driver is removed
+ * from memory.
+ */
+static void __exit idpf_module_exit(void)
+{
+	pci_unregister_driver(&idpf_driver);
+	pr_info("module unloaded\n");
+}
+module_exit(idpf_module_exit);
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +5 -0
new file mode 100644
index 000000000000..d0ea6c495c62
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2019 Intel Corporation */
+
+#include "idpf_dev.h"
+#include "iecm_lan_pf_regs.h"

drivers/net/ethernet/intel/idpf/idpf_reg.c line 15

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +10 -0
+
+/**
+ * idpf_ctlq_reg_init - initialize default mailbox registers
+ * @cq: pointer to the array of create control queues
+ */
+void idpf_ctlq_reg_init(struct iecm_ctlq_create_info *cq)
+{
+	int i;
+
+#define NUM_Q 2

I'd like to see it defined outside the function and with a bit of explanation of what that is.

Quoted 51 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +51 -0
+	for (i = 0; i < NUM_Q; i++) {
+		struct iecm_ctlq_create_info *ccq = cq + i;
+
+		switch (ccq->type) {
+		case IECM_CTLQ_TYPE_MAILBOX_TX:
+			/* set head and tail registers in our local struct */
+			ccq->reg.head = PF_FW_ATQH;
+			ccq->reg.tail = PF_FW_ATQT;
+			ccq->reg.len = PF_FW_ATQLEN;
+			ccq->reg.bah = PF_FW_ATQBAH;
+			ccq->reg.bal = PF_FW_ATQBAL;
+			ccq->reg.len_mask = PF_FW_ATQLEN_ATQLEN_M;
+			ccq->reg.len_ena_mask = PF_FW_ATQLEN_ATQENABLE_M;
+			ccq->reg.head_mask = PF_FW_ATQH_ATQH_M;
+			break;
+		case IECM_CTLQ_TYPE_MAILBOX_RX:
+			/* set head and tail registers in our local struct */
+			ccq->reg.head = PF_FW_ARQH;
+			ccq->reg.tail = PF_FW_ARQT;
+			ccq->reg.len = PF_FW_ARQLEN;
+			ccq->reg.bah = PF_FW_ARQBAH;
+			ccq->reg.bal = PF_FW_ARQBAL;
+			ccq->reg.len_mask = PF_FW_ARQLEN_ARQLEN_M;
+			ccq->reg.len_ena_mask = PF_FW_ARQLEN_ARQENABLE_M;
+			ccq->reg.head_mask = PF_FW_ARQH_ARQH_M;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+/**
+ * idpf_mb_intr_reg_init - Initialize mailbox interrupt register
+ * @adapter: adapter structure
+ */
+void idpf_mb_intr_reg_init(struct iecm_adapter *adapter)
+{
+	struct iecm_intr_reg *intr = &adapter->mb_vector.intr_reg;
+	struct virtchnl2_get_capabilities *caps;
+
+	caps = (struct virtchnl2_get_capabilities *)adapter->caps;
+	intr->dyn_ctl = le32_to_cpu(caps->mailbox_dyn_ctl);
+	intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
+	intr->dyn_ctl_itridx_m = PF_GLINT_DYN_CTL_ITR_INDX_M;
+	intr->icr_ena = PF_INT_DIR_OICR_ENA;
+	intr->icr_ena_ctlq_m = PF_INT_DIR_OICR_ENA_M;
+}
+
+/**
+ * idpf_intr_reg_init - Initialize interrupt registers

drivers/net/ethernet/intel/idpf/idpf_reg.c line 76

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +10 -0
+ * @vport: virtual port structure
+ */
+int idpf_intr_reg_init(struct iecm_vport *vport)
+{
+	int num_vecs = vport->num_q_vectors;
+	struct iecm_vec_regs *reg_vals;
+	int num_regs, i, err = 0;
+
+	reg_vals = kmalloc(sizeof(void *) * IECM_LARGE_MAX_Q,
+			   GFP_KERNEL);
	array_size(IECM_LARGE_MAX_Q, sizeof(void *));
Quoted 193 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +54 -0
+	if (!reg_vals)
+		return -ENOMEM;
+
+	num_regs = iecm_get_reg_intr_vecs(vport, reg_vals, num_vecs);
+	if (num_regs != num_vecs) {
+		err = -EINVAL;
+		goto free_reg_vals;
+	}
+
+	for (i = 0; i < num_regs; i++) {
+		struct iecm_q_vector *q_vector = &vport->q_vectors[i];
+		struct iecm_intr_reg *intr = &q_vector->intr_reg;
+
+		intr->dyn_ctl = reg_vals[i].dyn_ctl_reg;
+		intr->dyn_ctl_clrpba_m = PF_GLINT_DYN_CTL_CLEARPBA_M;
+		intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
+		intr->dyn_ctl_itridx_s = PF_GLINT_DYN_CTL_ITR_INDX_S;
+		intr->dyn_ctl_intrvl_s = PF_GLINT_DYN_CTL_INTERVAL_S;
+
+		intr->rx_itr = PF_GLINT_ITR_V2(VIRTCHNL2_ITR_IDX_0,
+					       reg_vals[i].itrn_reg);
+		intr->tx_itr = PF_GLINT_ITR_V2(VIRTCHNL2_ITR_IDX_1,
+					       reg_vals[i].itrn_reg);
+	}
+
+free_reg_vals:
+	kfree(reg_vals);
+	return err;
+}
+
+/**
+ * idpf_reset_reg_init - Initialize reset registers
+ * @reset_reg: struct to be filled in with reset registers
+ */
+void idpf_reset_reg_init(struct iecm_reset_reg *reset_reg)
+{
+	reset_reg->rstat = PFGEN_RSTAT;
+	reset_reg->rstat_m = PFGEN_RSTAT_PFR_STATE_M;
+}
+
+/**
+ * idpf_trigger_reset - trigger reset
+ * @adapter: Driver specific private structure
+ * @trig_cause: Reason to trigger a reset
+ */
+void idpf_trigger_reset(struct iecm_adapter *adapter,
+			enum iecm_flags __always_unused trig_cause)
+{
+	u32 reset_reg;
+
+	reset_reg = rd32(&adapter->hw, PFGEN_CTRL);
+	wr32(&adapter->hw, PFGEN_CTRL, (reset_reg | PFGEN_CTRL_PFSWR));
+}
+
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +131 -0
new file mode 100644
index 000000000000..52ffe5c4a7ca
@@ -0,0 +1,131 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2020, Intel Corporation. */
+
+#ifndef _IECM_LAN_PF_REGS_H_
+#define _IECM_LAN_PF_REGS_H_
+
+/* Receive queues */
+#define PF_QRX_BASE			0x00000000
+#define PF_QRX_TAIL(_QRX)		(PF_QRX_BASE + (((_QRX) * 0x1000)))
+#define PF_QRX_BUFFQ_BASE		0x03000000
+#define PF_QRX_BUFFQ_TAIL(_QRX)		(PF_QRX_BUFFQ_BASE + (((_QRX) * 0x1000)))
+
+/* Transmit queues */
+#define PF_QTX_BASE			0x05000000
+#define PF_QTX_COMM_DBELL(_DBQM)	(PF_QTX_BASE + ((_DBQM) * 0x1000))
+
+/* Control(PF Mailbox) Queue */
+#define PF_FW_BASE			0x08400000
+
+#define PF_FW_ARQBAL			(PF_FW_BASE)
+#define PF_FW_ARQBAH			(PF_FW_BASE + 0x4)
+#define PF_FW_ARQLEN			(PF_FW_BASE + 0x8)
+#define PF_FW_ARQLEN_ARQLEN_S		0
+#define PF_FW_ARQLEN_ARQLEN_M		MAKEMASK(0x1FFF, PF_FW_ARQLEN_ARQLEN_S)
+#define PF_FW_ARQLEN_ARQVFE_S		28
+#define PF_FW_ARQLEN_ARQVFE_M		BIT(PF_FW_ARQLEN_ARQVFE_S)
+#define PF_FW_ARQLEN_ARQOVFL_S		29
+#define PF_FW_ARQLEN_ARQOVFL_M		BIT(PF_FW_ARQLEN_ARQOVFL_S)
+#define PF_FW_ARQLEN_ARQCRIT_S		30
+#define PF_FW_ARQLEN_ARQCRIT_M		BIT(PF_FW_ARQLEN_ARQCRIT_S)
+#define PF_FW_ARQLEN_ARQENABLE_S	31
+#define PF_FW_ARQLEN_ARQENABLE_M	BIT(PF_FW_ARQLEN_ARQENABLE_S)
+#define PF_FW_ARQH			(PF_FW_BASE + 0xC)
+#define PF_FW_ARQH_ARQH_S		0
+#define PF_FW_ARQH_ARQH_M		MAKEMASK(0x1FFF, PF_FW_ARQH_ARQH_S)
+#define PF_FW_ARQT			(PF_FW_BASE + 0x10)
+
+#define PF_FW_ATQBAL			(PF_FW_BASE + 0x14)
+#define PF_FW_ATQBAH			(PF_FW_BASE + 0x18)
+#define PF_FW_ATQLEN			(PF_FW_BASE + 0x1C)
+#define PF_FW_ATQLEN_ATQLEN_S		0
+#define PF_FW_ATQLEN_ATQLEN_M		MAKEMASK(0x3FF, PF_FW_ATQLEN_ATQLEN_S)
+#define PF_FW_ATQLEN_ATQVFE_S		28
+#define PF_FW_ATQLEN_ATQVFE_M		BIT(PF_FW_ATQLEN_ATQVFE_S)
+#define PF_FW_ATQLEN_ATQOVFL_S		29
+#define PF_FW_ATQLEN_ATQOVFL_M		BIT(PF_FW_ATQLEN_ATQOVFL_S)
+#define PF_FW_ATQLEN_ATQCRIT_S		30
+#define PF_FW_ATQLEN_ATQCRIT_M		BIT(PF_FW_ATQLEN_ATQCRIT_S)
+#define PF_FW_ATQLEN_ATQENABLE_S	31
+#define PF_FW_ATQLEN_ATQENABLE_M	BIT(PF_FW_ATQLEN_ATQENABLE_S)
+#define PF_FW_ATQH			(PF_FW_BASE + 0x20)
+#define PF_FW_ATQH_ATQH_S		0
+#define PF_FW_ATQH_ATQH_M		MAKEMASK(0x3FF, PF_FW_ATQH_ATQH_S)
+#define PF_FW_ATQT			(PF_FW_BASE + 0x24)
+
+/* Interrupts */
+#define PF_GLINT_BASE			0x08900000
+#define PF_GLINT_DYN_CTL(_INT)		(PF_GLINT_BASE + ((_INT) * 0x1000))
+#define PF_GLINT_DYN_CTL_INTENA_S	0
+#define PF_GLINT_DYN_CTL_INTENA_M	BIT(PF_GLINT_DYN_CTL_INTENA_S)
+#define PF_GLINT_DYN_CTL_CLEARPBA_S	1
+#define PF_GLINT_DYN_CTL_CLEARPBA_M	BIT(PF_GLINT_DYN_CTL_CLEARPBA_S)
+#define PF_GLINT_DYN_CTL_SWINT_TRIG_S	2
+#define PF_GLINT_DYN_CTL_SWINT_TRIG_M	BIT(PF_GLINT_DYN_CTL_SWINT_TRIG_S)
+#define PF_GLINT_DYN_CTL_ITR_INDX_S	3
+#define PF_GLINT_DYN_CTL_ITR_INDX_M	MAKEMASK(0x3, PF_GLINT_DYN_CTL_ITR_INDX_S)
+#define PF_GLINT_DYN_CTL_INTERVAL_S	5
+#define PF_GLINT_DYN_CTL_INTERVAL_M	BIT(PF_GLINT_DYN_CTL_INTERVAL_S)
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_S	24
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_M BIT(PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_S)
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_S	25
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_M	BIT(PF_GLINT_DYN_CTL_SW_ITR_INDX_S)
+#define PF_GLINT_DYN_CTL_WB_ON_ITR_S	30
+#define PF_GLINT_DYN_CTL_WB_ON_ITR_M	BIT(PF_GLINT_DYN_CTL_WB_ON_ITR_S)
+#define PF_GLINT_DYN_CTL_INTENA_MSK_S	31
+#define PF_GLINT_DYN_CTL_INTENA_MSK_M	BIT(PF_GLINT_DYN_CTL_INTENA_MSK_S)
+#define PF_GLINT_ITR_V2(_i, _reg_start) (((_i) * 4) + (_reg_start))
+#define PF_GLINT_ITR(_i, _INT) (PF_GLINT_BASE + (((_i) + 1) * 4) + ((_INT) * 0x1000))
+#define PF_GLINT_ITR_MAX_INDEX		2
+#define PF_GLINT_ITR_INTERVAL_S		0
+#define PF_GLINT_ITR_INTERVAL_M		MAKEMASK(0xFFF, PF_GLINT_ITR_INTERVAL_S)
+
+/* Timesync registers */
+#define PF_TIMESYNC_BASE		0x08404000
+#define PF_GLTSYN_CMD_SYNC		(PF_TIMESYNC_BASE)
+#define PF_GLTSYN_CMD_SYNC_EXEC_CMD_S	0
+#define PF_GLTSYN_CMD_SYNC_EXEC_CMD_M	MAKEMASK(0x3, PF_GLTSYN_CMD_SYNC_EXEC_CMD_S)
+#define PF_GLTSYN_CMD_SYNC_SHTIME_EN_S	2
+#define PF_GLTSYN_CMD_SYNC_SHTIME_EN_M	BIT(PF_GLTSYN_CMD_SYNC_SHTIME_EN_S)
+#define PF_GLTSYN_SHTIME_0		(PF_TIMESYNC_BASE + 0x4)
+#define PF_GLTSYN_SHTIME_L		(PF_TIMESYNC_BASE + 0x8)
+#define PF_GLTSYN_SHTIME_H		(PF_TIMESYNC_BASE + 0xC)
+#define PF_GLTSYN_ART_L			(PF_TIMESYNC_BASE + 0x10)
+#define PF_GLTSYN_ART_H			(PF_TIMESYNC_BASE + 0x14)
+
+/* Generic registers */
+#define PF_INT_DIR_OICR_ENA		0x08406000
+#define PF_INT_DIR_OICR_ENA_S		0
+#define PF_INT_DIR_OICR_ENA_M	MAKEMASK(0xFFFFFFFF, PF_INT_DIR_OICR_ENA_S)
+#define PF_INT_DIR_OICR			0x08406004
+#define PF_INT_DIR_OICR_TSYN_EVNT	0
+#define PF_INT_DIR_OICR_PHY_TS_0	BIT(1)
+#define PF_INT_DIR_OICR_PHY_TS_1	BIT(2)
+#define PF_INT_DIR_OICR_CAUSE		0x08406008
+#define PF_INT_DIR_OICR_CAUSE_CAUSE_S	0
+#define PF_INT_DIR_OICR_CAUSE_CAUSE_M	MAKEMASK(0xFFFFFFFF, PF_INT_DIR_OICR_CAUSE_CAUSE_S)
+#define PF_INT_PBA_CLEAR		0x0840600C
+
+#define PF_FUNC_RID			0x08406010
+#define PF_FUNC_RID_FUNCTION_NUMBER_S	0
+#define PF_FUNC_RID_FUNCTION_NUMBER_M	MAKEMASK(0x7, PF_FUNC_RID_FUNCTION_NUMBER_S)
+#define PF_FUNC_RID_DEVICE_NUMBER_S	3
+#define PF_FUNC_RID_DEVICE_NUMBER_M	MAKEMASK(0x1F, PF_FUNC_RID_DEVICE_NUMBER_S)
+#define PF_FUNC_RID_BUS_NUMBER_S	8
+#define PF_FUNC_RID_BUS_NUMBER_M	MAKEMASK(0xFF, PF_FUNC_RID_BUS_NUMBER_S)
+
+/* Reset registers */
+#define PFGEN_RTRIG			0x08407000
+#define PFGEN_RTRIG_CORER_S		0
+#define PFGEN_RTRIG_CORER_M		BIT(0)
+#define PFGEN_RTRIG_LINKR_S		1
+#define PFGEN_RTRIG_LINKR_M		BIT(1)
+#define PFGEN_RTRIG_IMCR_S		2
+#define PFGEN_RTRIG_IMCR_M		BIT(2)
+#define PFGEN_RSTAT			0x08407008 /* PFR Status */
+#define PFGEN_RSTAT_PFR_STATE_S		0
+#define PFGEN_RSTAT_PFR_STATE_M		MAKEMASK(0x3, PFGEN_RSTAT_PFR_STATE_S)
+#define PFGEN_CTRL			0x0840700C
+#define PFGEN_CTRL_PFSWR		BIT(0)
+
+#endif
Signature · 1 line
2.33.0

Thanks,
Al

#80 lore raw

PATCH 19/19 idpf: introduce idpf driver

Quoted 18 lines

-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 12:08 PM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 19/19] idpf: introduce idpf driver

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:09 -0800

Quoted 3 lines

This adds the idpf driver which uses the iecm module to provide common functionality. Device specific behavior and registers are defined here and handed off to iecm which takes over the rest of the flow.

Quoted 9 lines

Ok I missed that before, so I say it now.
Multi-function networking devices (Ethernet, SFs, VF representors, RDMA, storage offload etc.) nowadays kinda *must* be based on top of auxiliary bus. Otherwise, maintaining of hundreds a direct call with recursive dependencies between modules and stuff will become a burden.
All of the mentioned functionality will be added to the driver(s), that's a fact, and as these are new drivers, it's way better to start off the right way now than to bug your mind on how to refactor this later.

I suspect a refactor now will actually be more painful than later for other reasons and I believe we have other motivations for not using aux bus in this. It is however worth considering but we need some time to discuss. Will reply with something firm after some internal discussion.

Quoted 217 lines
Quoted 6 lines
Quoted 8 lines
---
 .../device_drivers/ethernet/intel/idpf.rst    |  47 ++++++
 drivers/net/ethernet/intel/Kconfig            |  16 ++
 drivers/net/ethernet/intel/Makefile           |   1 +
 drivers/net/ethernet/intel/idpf/Makefile      |  15 ++
 drivers/net/ethernet/intel/idpf/idpf_dev.h    |  17 +++
 drivers/net/ethernet/intel/idpf/idpf_devids.h |  10 ++
 drivers/net/ethernet/intel/idpf/idpf_main.c   | 140

++++++++++++++++++

Quoted 22 lines
 drivers/net/ethernet/intel/idpf/idpf_reg.c    | 130 ++++++++++++++++
 .../ethernet/intel/include/iecm_lan_pf_regs.h | 131 ++++++++++++++++
 9 files changed, 507 insertions(+)
 create mode 100644
Documentation/networking/device_drivers/ethernet/intel/idpf.rst
 create mode 100644 drivers/net/ethernet/intel/idpf/Makefile
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_reg.c
 create mode 100644

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

diff --git a/Documentation/networking/device_drivers/ethernet/intel/idpf.rst b/Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file mode 100644
index 000000000000..973fa9613428

Documentation/networking/device_drivers/ethernet/intel/idpf.rst line 2

Quoted 2 lines
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +2 -0
@@ -0,0 +1,47 @@
+.. SPDX-License-Identifier: GPL-2.0
+

+=========================================================
=========

Documentation/networking/device_drivers/ethernet/intel/idpf.rst line 4

Quoted 3 lines
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +2 -0
+Linux Base Driver for the Intel(R) Smart Network Adapter Family
+Series

+=========================================================
=========

Quoted 53 lines
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +42 -0
+
+Intel idpf Linux driver.
+Copyright(c) 2020 Intel Corporation.
+
+Contents
+========
+
+- Enabling the driver
+- Support
+
+The driver in this release supports Intel's Smart Network Adapter
+Family Series of products. For more information, visit Intel's
+support page at https://support.intel.com.
+
+Enabling the driver
+===================
+The driver is enabled via the standard kernel configuration system,
+using the make command::
+
+  make oldconfig/menuconfig/etc.
+
+The driver is located in the menu structure at:
+
+  -> Device Drivers
+    -> Network device support (NETDEVICES [=y])
+      -> Ethernet driver support
+        -> Intel devices
+          -> Intel(R) Smart Network Adapter Family Series Support
+
+Support
+=======
+For general information, go to the Intel support website at:
+
+https://www.intel.com/support/
+
+or the Intel Wired Networking project hosted by Sourceforge at:
+
+https://sourceforge.net/projects/e1000
+
+If an issue is identified with the released source code on a
+supported kernel with a supported adapter, email the specific
+information related to the issue to e1000-devel at lists.sf.net.
drivers/net/ethernet/intel/Kconfig +2 -0
index 754dc7677ad5..93c8883c22ad 100644
@@ -387,4 +387,20 @@ config IECM
       To compile this as a module, choose M here. The module will be called
       iecm.
 
+config IDPF
+	tristate "Intel(R) Data Plane Function Support"

drivers/net/ethernet/intel/Kconfig config IECM · line 401

Quoted 10 lines
drivers/net/ethernet/intel/Kconfig +10 -0
+	default n
+	depends on IECM
+	help
+	  For more information on how to identify your adapter, go
+	  to the Adapter & Driver ID Guide that can be located at:
+
+	  <http://support.intel.com>
+
+	  More specific information on configuring the driver is in
+

<file:Documentation/networking/device_drivers/ethernet/intel/idpf.rst>.

Quoted 96 lines
drivers/net/ethernet/intel/Kconfig +4 -0
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called idpf.
+
 endif # NET_VENDOR_INTEL
drivers/net/ethernet/intel/Makefile +1 -0
index c9eba9cc5087..3786c2269f3d 100644
@@ -17,3 +17,4 @@ obj-$(CONFIG_IAVF) += iavf/
 obj-$(CONFIG_FM10K) += fm10k/
 obj-$(CONFIG_ICE) += ice/
 obj-$(CONFIG_IECM) += iecm/
+obj-$(CONFIG_IDPF) += idpf/
drivers/net/ethernet/intel/idpf/Makefile new file +14 -0
new file mode 100644
index 000000000000..85846620bc9f
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only # Copyright (C) 2019 Intel
+Corporation
+
+#
+# Makefile for the Intel(R) Data Plane Function Linux Driver #
+
+obj-$(CONFIG_IDPF) += idpf.o
+
+ccflags-y += -I$(srctree)/drivers/net/ethernet/intel/include \
+			 -I$(srctree)/include/linux/avf
+
+idpf-y := \
+	idpf_main.o \
+	idpf_reg.o
drivers/net/ethernet/intel/idpf/idpf_dev.h new file +17 -0
new file mode 100644
index 000000000000..dc146161f884
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2019 Intel Corporation */
+
+#ifndef _IDPF_DEV_H_
+#define _IDPF_DEV_H_
+
+#include "iecm.h"
+
+int idpf_intr_reg_init(struct iecm_vport *vport); void
+idpf_mb_intr_reg_init(struct iecm_adapter *adapter); void
+idpf_reset_reg_init(struct iecm_reset_reg *reset_reg); void
+idpf_trigger_reset(struct iecm_adapter *adapter,
+			enum iecm_flags trig_cause);
+void idpf_vportq_reg_init(struct iecm_vport *vport); void
+idpf_ctlq_reg_init(struct iecm_ctlq_create_info *cq);
+
+#endif /* _IDPF_DEV_H_ */
drivers/net/ethernet/intel/idpf/idpf_devids.h new file +10 -0
new file mode 100644
index 000000000000..7bf8eb64b76a
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2019 Intel Corporation */
+
+#ifndef _IDPF_DEVIDS_H_
+#define _IDPF_DEVIDS_H_
+
+/* Device IDs */
+#define IDPF_DEV_ID_PF			0x1452
+
+#endif /* _IDPF_DEVIDS_H_ */
drivers/net/ethernet/intel/idpf/idpf_main.c new file +12 -0
new file mode 100644
index 000000000000..da5e668beabf
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2019 Intel Corporation */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include "idpf_dev.h"
+#include "idpf_devids.h"
+
+#define DRV_SUMMARY	"Intel(R) Data Plane Function Linux Driver"
+static const char idpf_driver_string[] = DRV_SUMMARY; static const
+char idpf_copyright[] = "Copyright (c) 2020, Intel Corporation.";
+

drivers/net/ethernet/intel/idpf/idpf_main.c line 22

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +10 -0
+MODULE_DESCRIPTION(DRV_SUMMARY);
+MODULE_LICENSE("GPL");
+
+/**
+ * idpf_reg_ops_init - Initialize register API function pointers
+ * @adapter: Driver specific private structure  */ static void
+idpf_reg_ops_init(struct iecm_adapter *adapter) {
+	adapter->dev_ops.reg_ops.ctlq_reg_init = idpf_ctlq_reg_init;
+	adapter->dev_ops.reg_ops.intr_reg_init = idpf_intr_reg_init;
+	adapter->dev_ops.reg_ops.mb_intr_reg_init =

idpf_mb_intr_reg_init;

Quoted 6 lines

drivers/net/ethernet/intel/idpf/idpf_main.c line 26

Quoted 2 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +2 -0
+	adapter->dev_ops.reg_ops.reset_reg_init = idpf_reset_reg_init;
+	adapter->dev_ops.reg_ops.trigger_reset = idpf_trigger_reset;

Why not define static const reg_ops for idpf and assigning it? Filling plenty of callbacks inside functions are generally discouraged.

Seems reasonable, will check.

Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +4 -0
+}
+
+/**
+ * idpf_probe - Device initialization routine
Quoted 9 lines

drivers/net/ethernet/intel/idpf/idpf_main.c line 37

Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6 -0
+ * @pdev: PCI device information struct
+ * @ent: entry in idpf_pci_tbl
+ *
+ * Returns 0 on success, negative on failure  */ static int
+idpf_probe(struct pci_dev *pdev,
+		      const struct pci_device_id __always_unused *ent)

Again, no __always_unused for function parameters.

Will not fix.

Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +4 -0
+{
+	struct iecm_adapter *adapter = NULL;
+	int err;
+
Quoted 9 lines

drivers/net/ethernet/intel/idpf/idpf_main.c line 46

Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +5 -0
+	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
+	if (!adapter)
+		return -ENOMEM;
+
+	adapter->dev_ops.reg_ops_init = idpf_reg_ops_init;

Why not just directly assign callbacks here? Callback for filling more callbacks?

It was mostly following the pattern we had initially established for setting up vc_ops, which does have a good excuse to be callback to assign callbacks, but you're right I can't justify doing this for reg_ops, will fix.

Quoted 103 lines
Quoted 56 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +56 -0
+	set_bit(__IECM_REQ_TX_SPLITQ, adapter->flags);
+	set_bit(__IECM_REQ_RX_SPLITQ, adapter->flags);
+
+	err = iecm_probe(pdev, ent, adapter);
+	if (err)
+		kfree(adapter);
+
+	return err;
+}
+
+/**
+ * idpf_remove - Device removal routine
+ * @pdev: PCI device information struct  */ static void
+idpf_remove(struct pci_dev *pdev) {
+	struct iecm_adapter *adapter = pci_get_drvdata(pdev);
+
+	if (!adapter)
+		return;
+
+	iecm_remove(pdev);
+	pci_set_drvdata(pdev, NULL);
+	kfree(adapter);
+}
+
+/**
+ * idpf_shutdown - PCI callback for shutting down device
+ * @pdev: PCI device information struct  */ static void
+idpf_shutdown(struct pci_dev *pdev) {
+	idpf_remove(pdev);
+
+	if (system_state == SYSTEM_POWER_OFF)
+		pci_set_power_state(pdev, PCI_D3hot); }
+
+/* idpf_pci_tbl - PCI Dev iapf ID Table
+ *
+ * Wildcard entries (PCI_ANY_ID) should come last
+ * Last entry must be all 0s
+ *
+ * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
+ *   Class, Class Mask, private data (not used) }
+ */
+static const struct pci_device_id idpf_pci_tbl[] = {
+	{ PCI_VDEVICE(INTEL, IDPF_DEV_ID_PF), 0 },
+	/* required last entry */
+	{ 0, }
+};
+MODULE_DEVICE_TABLE(pci, idpf_pci_tbl);
+
+static struct pci_driver idpf_driver = {
+	.name = KBUILD_MODNAME,
+	.id_table = idpf_pci_tbl,
+	.probe = idpf_probe,
+	.remove = idpf_remove,
+	.shutdown = idpf_shutdown,
+};
+

drivers/net/ethernet/intel/idpf/idpf_main.c

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +10 -0
+/**
+ * idpf_module_init - Driver registration routine
+ *
+ * idpf_module_init is the first routine called when the driver is
+ * loaded. All it does is register with the PCI subsystem.
+ */
+static int __init idpf_module_init(void) {
+	int status;
+
+	pr_info("%s - version %d\n", idpf_driver_string,

LINUX_VERSION_CODE);

Quoted 36 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +21 -0
+	pr_info("%s\n", idpf_copyright);
+
+	status = pci_register_driver(&idpf_driver);
+	if (status)
+		pr_err("failed to register pci driver, err %d\n", status);
+
+	return status;
+}
+module_init(idpf_module_init);
+
+/**
+ * idpf_module_exit - Driver exit cleanup routine
+ *
+ * idpf_module_exit is called just before the driver is removed
+ * from memory.
+ */
+static void __exit idpf_module_exit(void) {
+	pci_unregister_driver(&idpf_driver);
+	pr_info("module unloaded\n");
+}
+module_exit(idpf_module_exit);
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +8 -0
new file mode 100644
index 000000000000..d0ea6c495c62
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2019 Intel Corporation */
+
+#include "idpf_dev.h"
+#include "iecm_lan_pf_regs.h"
+
+/**
+ * idpf_ctlq_reg_init - initialize default mailbox registers
Quoted 9 lines

drivers/net/ethernet/intel/idpf/idpf_reg.c line 15

Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +5 -0
+ * @cq: pointer to the array of create control queues  */ void
+idpf_ctlq_reg_init(struct iecm_ctlq_create_info *cq) {
+	int i;
+
+#define NUM_Q 2

I'd like to see it defined outside the function and with a bit of explanation of what that is.

Sure will fix.

Quoted 292 lines

drivers/net/ethernet/intel/idpf/idpf_reg.c

Quoted 13 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +13 -0
+	for (i = 0; i < NUM_Q; i++) {
+		struct iecm_ctlq_create_info *ccq = cq + i;
+
+		switch (ccq->type) {
+		case IECM_CTLQ_TYPE_MAILBOX_TX:
+			/* set head and tail registers in our local struct */
+			ccq->reg.head = PF_FW_ATQH;
+			ccq->reg.tail = PF_FW_ATQT;
+			ccq->reg.len = PF_FW_ATQLEN;
+			ccq->reg.bah = PF_FW_ATQBAH;
+			ccq->reg.bal = PF_FW_ATQBAL;
+			ccq->reg.len_mask = PF_FW_ATQLEN_ATQLEN_M;
+			ccq->reg.len_ena_mask =

PF_FW_ATQLEN_ATQENABLE_M;

drivers/net/ethernet/intel/idpf/idpf_reg.c

Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +11 -0
+			ccq->reg.head_mask = PF_FW_ATQH_ATQH_M;
+			break;
+		case IECM_CTLQ_TYPE_MAILBOX_RX:
+			/* set head and tail registers in our local struct */
+			ccq->reg.head = PF_FW_ARQH;
+			ccq->reg.tail = PF_FW_ARQT;
+			ccq->reg.len = PF_FW_ARQLEN;
+			ccq->reg.bah = PF_FW_ARQBAH;
+			ccq->reg.bal = PF_FW_ARQBAL;
+			ccq->reg.len_mask = PF_FW_ARQLEN_ARQLEN_M;
+			ccq->reg.len_ena_mask =

PF_FW_ARQLEN_ARQENABLE_M;

Quoted 24 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +24 -0
+			ccq->reg.head_mask = PF_FW_ARQH_ARQH_M;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+/**
+ * idpf_mb_intr_reg_init - Initialize mailbox interrupt register
+ * @adapter: adapter structure
+ */
+void idpf_mb_intr_reg_init(struct iecm_adapter *adapter) {
+	struct iecm_intr_reg *intr = &adapter->mb_vector.intr_reg;
+	struct virtchnl2_get_capabilities *caps;
+
+	caps = (struct virtchnl2_get_capabilities *)adapter->caps;
+	intr->dyn_ctl = le32_to_cpu(caps->mailbox_dyn_ctl);
+	intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
+	intr->dyn_ctl_itridx_m = PF_GLINT_DYN_CTL_ITR_INDX_M;
+	intr->icr_ena = PF_INT_DIR_OICR_ENA;
+	intr->icr_ena_ctlq_m = PF_INT_DIR_OICR_ENA_M; }
+
+/**

drivers/net/ethernet/intel/idpf/idpf_reg.c line 76

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +10 -0
+ * idpf_intr_reg_init - Initialize interrupt registers
+ * @vport: virtual port structure
+ */
+int idpf_intr_reg_init(struct iecm_vport *vport) {
+	int num_vecs = vport->num_q_vectors;
+	struct iecm_vec_regs *reg_vals;
+	int num_regs, i, err = 0;
+
+	reg_vals = kmalloc(sizeof(void *) * IECM_LARGE_MAX_Q,
+			   GFP_KERNEL);
	array_size(IECM_LARGE_MAX_Q, sizeof(void *));
Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +5 -0
+	if (!reg_vals)
+		return -ENOMEM;
+
+	num_regs = iecm_get_reg_intr_vecs(vport, reg_vals, num_vecs);
+	if (num_regs != num_vecs) {

drivers/net/ethernet/intel/idpf/idpf_reg.c

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +10 -0
+		err = -EINVAL;
+		goto free_reg_vals;
+	}
+
+	for (i = 0; i < num_regs; i++) {
+		struct iecm_q_vector *q_vector = &vport->q_vectors[i];
+		struct iecm_intr_reg *intr = &q_vector->intr_reg;
+
+		intr->dyn_ctl = reg_vals[i].dyn_ctl_reg;
+		intr->dyn_ctl_clrpba_m =

PF_GLINT_DYN_CTL_CLEARPBA_M;

Quoted 22 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +22 -0
+		intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
+		intr->dyn_ctl_itridx_s = PF_GLINT_DYN_CTL_ITR_INDX_S;
+		intr->dyn_ctl_intrvl_s = PF_GLINT_DYN_CTL_INTERVAL_S;
+
+		intr->rx_itr = PF_GLINT_ITR_V2(VIRTCHNL2_ITR_IDX_0,
+					       reg_vals[i].itrn_reg);
+		intr->tx_itr = PF_GLINT_ITR_V2(VIRTCHNL2_ITR_IDX_1,
+					       reg_vals[i].itrn_reg);
+	}
+
+free_reg_vals:
+	kfree(reg_vals);
+	return err;
+}
+
+/**
+ * idpf_reset_reg_init - Initialize reset registers
+ * @reset_reg: struct to be filled in with reset registers  */ void
+idpf_reset_reg_init(struct iecm_reset_reg *reset_reg) {
+	reset_reg->rstat = PFGEN_RSTAT;
+	reset_reg->rstat_m = PFGEN_RSTAT_PFR_STATE_M; }
+

drivers/net/ethernet/intel/idpf/idpf_reg.c

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +10 -0
+/**
+ * idpf_trigger_reset - trigger reset
+ * @adapter: Driver specific private structure
+ * @trig_cause: Reason to trigger a reset  */ void
+idpf_trigger_reset(struct iecm_adapter *adapter,
+			enum iecm_flags __always_unused trig_cause) {
+	u32 reset_reg;
+
+	reset_reg = rd32(&adapter->hw, PFGEN_CTRL);
+	wr32(&adapter->hw, PFGEN_CTRL, (reset_reg |

PFGEN_CTRL_PFSWR)); }

Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_reg.c new file +1 -0
+
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +0 -0
new file mode 100644
index 000000000000..52ffe5c4a7ca

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 9

Quoted 9 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +9 -0
@@ -0,0 +1,131 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2020, Intel Corporation. */
+
+#ifndef _IECM_LAN_PF_REGS_H_
+#define _IECM_LAN_PF_REGS_H_
+
+/* Receive queues */
+#define PF_QRX_BASE			0x00000000
+#define PF_QRX_TAIL(_QRX)		(PF_QRX_BASE + (((_QRX) *

0x1000)))

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 11

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_QRX_BUFFQ_BASE		0x03000000
+#define PF_QRX_BUFFQ_TAIL(_QRX)
	(PF_QRX_BUFFQ_BASE + (((_QRX) * 0x1000)))

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 4 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +4 -0
+
+/* Transmit queues */
+#define PF_QTX_BASE			0x05000000
+#define PF_QTX_COMM_DBELL(_DBQM)	(PF_QTX_BASE + ((_DBQM) *

0x1000))

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 9 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +9 -0
+
+/* Control(PF Mailbox) Queue */
+#define PF_FW_BASE			0x08400000
+
+#define PF_FW_ARQBAL			(PF_FW_BASE)
+#define PF_FW_ARQBAH			(PF_FW_BASE + 0x4)
+#define PF_FW_ARQLEN			(PF_FW_BASE + 0x8)
+#define PF_FW_ARQLEN_ARQLEN_S		0
+#define PF_FW_ARQLEN_ARQLEN_M		MAKEMASK(0x1FFF,

PF_FW_ARQLEN_ARQLEN_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 26

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ARQLEN_ARQVFE_S		28
+#define PF_FW_ARQLEN_ARQVFE_M

BIT(PF_FW_ARQLEN_ARQVFE_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 28

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ARQLEN_ARQOVFL_S		29
+#define PF_FW_ARQLEN_ARQOVFL_M

BIT(PF_FW_ARQLEN_ARQOVFL_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 30

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ARQLEN_ARQCRIT_S		30
+#define PF_FW_ARQLEN_ARQCRIT_M

BIT(PF_FW_ARQLEN_ARQCRIT_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 32

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ARQLEN_ARQENABLE_S	31
+#define PF_FW_ARQLEN_ARQENABLE_M

BIT(PF_FW_ARQLEN_ARQENABLE_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 3 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +3 -0
+#define PF_FW_ARQH			(PF_FW_BASE + 0xC)
+#define PF_FW_ARQH_ARQH_S		0
+#define PF_FW_ARQH_ARQH_M		MAKEMASK(0x1FFF,

PF_FW_ARQH_ARQH_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 7 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +7 -0
+#define PF_FW_ARQT			(PF_FW_BASE + 0x10)
+
+#define PF_FW_ATQBAL			(PF_FW_BASE + 0x14)
+#define PF_FW_ATQBAH			(PF_FW_BASE + 0x18)
+#define PF_FW_ATQLEN			(PF_FW_BASE + 0x1C)
+#define PF_FW_ATQLEN_ATQLEN_S		0
+#define PF_FW_ATQLEN_ATQLEN_M		MAKEMASK(0x3FF,

PF_FW_ATQLEN_ATQLEN_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 44

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ATQLEN_ATQVFE_S		28
+#define PF_FW_ATQLEN_ATQVFE_M

BIT(PF_FW_ATQLEN_ATQVFE_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 46

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ATQLEN_ATQOVFL_S		29
+#define PF_FW_ATQLEN_ATQOVFL_M

BIT(PF_FW_ATQLEN_ATQOVFL_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 48

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ATQLEN_ATQCRIT_S		30
+#define PF_FW_ATQLEN_ATQCRIT_M

BIT(PF_FW_ATQLEN_ATQCRIT_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 50

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FW_ATQLEN_ATQENABLE_S	31
+#define PF_FW_ATQLEN_ATQENABLE_M

BIT(PF_FW_ATQLEN_ATQENABLE_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 3 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +3 -0
+#define PF_FW_ATQH			(PF_FW_BASE + 0x20)
+#define PF_FW_ATQH_ATQH_S		0
+#define PF_FW_ATQH_ATQH_M		MAKEMASK(0x3FF,

PF_FW_ATQH_ATQH_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 5 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +5 -0
+#define PF_FW_ATQT			(PF_FW_BASE + 0x24)
+
+/* Interrupts */
+#define PF_GLINT_BASE			0x08900000
+#define PF_GLINT_DYN_CTL(_INT)		(PF_GLINT_BASE + ((_INT) *

0x1000))

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 60

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_INTENA_S	0
+#define PF_GLINT_DYN_CTL_INTENA_M

BIT(PF_GLINT_DYN_CTL_INTENA_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 62

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_CLEARPBA_S	1
+#define PF_GLINT_DYN_CTL_CLEARPBA_M

BIT(PF_GLINT_DYN_CTL_CLEARPBA_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 64

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_SWINT_TRIG_S	2
+#define PF_GLINT_DYN_CTL_SWINT_TRIG_M

BIT(PF_GLINT_DYN_CTL_SWINT_TRIG_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 66

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_ITR_INDX_S	3
+#define PF_GLINT_DYN_CTL_ITR_INDX_M	MAKEMASK(0x3,

PF_GLINT_DYN_CTL_ITR_INDX_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 68

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_INTERVAL_S	5
+#define PF_GLINT_DYN_CTL_INTERVAL_M

BIT(PF_GLINT_DYN_CTL_INTERVAL_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 70

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_S	24
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_M

BIT(PF_GLINT_DYN_CTL_SW_ITR_INDX_ENA_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 72

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_S	25
+#define PF_GLINT_DYN_CTL_SW_ITR_INDX_M
	BIT(PF_GLINT_DYN_CTL_SW_ITR_INDX_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 74

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_WB_ON_ITR_S	30
+#define PF_GLINT_DYN_CTL_WB_ON_ITR_M
	BIT(PF_GLINT_DYN_CTL_WB_ON_ITR_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 76

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_DYN_CTL_INTENA_MSK_S	31
+#define PF_GLINT_DYN_CTL_INTENA_MSK_M

BIT(PF_GLINT_DYN_CTL_INTENA_MSK_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 78

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLINT_ITR_V2(_i, _reg_start) (((_i) * 4) + (_reg_start))
+#define PF_GLINT_ITR(_i, _INT) (PF_GLINT_BASE + (((_i) + 1) * 4) +

((_INT) * 0x1000))

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 3 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +3 -0
+#define PF_GLINT_ITR_MAX_INDEX		2
+#define PF_GLINT_ITR_INTERVAL_S		0
+#define PF_GLINT_ITR_INTERVAL_M		MAKEMASK(0xFFF,

PF_GLINT_ITR_INTERVAL_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 6 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +6 -0
+
+/* Timesync registers */
+#define PF_TIMESYNC_BASE		0x08404000
+#define PF_GLTSYN_CMD_SYNC		(PF_TIMESYNC_BASE)
+#define PF_GLTSYN_CMD_SYNC_EXEC_CMD_S	0
+#define PF_GLTSYN_CMD_SYNC_EXEC_CMD_M	MAKEMASK(0x3,

PF_GLTSYN_CMD_SYNC_EXEC_CMD_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 89

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_GLTSYN_CMD_SYNC_SHTIME_EN_S	2
+#define PF_GLTSYN_CMD_SYNC_SHTIME_EN_M

BIT(PF_GLTSYN_CMD_SYNC_SHTIME_EN_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 10 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +10 -0
+#define PF_GLTSYN_SHTIME_0		(PF_TIMESYNC_BASE + 0x4)
+#define PF_GLTSYN_SHTIME_L		(PF_TIMESYNC_BASE + 0x8)
+#define PF_GLTSYN_SHTIME_H		(PF_TIMESYNC_BASE + 0xC)
+#define PF_GLTSYN_ART_L			(PF_TIMESYNC_BASE + 0x10)
+#define PF_GLTSYN_ART_H			(PF_TIMESYNC_BASE + 0x14)
+
+/* Generic registers */
+#define PF_INT_DIR_OICR_ENA		0x08406000
+#define PF_INT_DIR_OICR_ENA_S		0
+#define PF_INT_DIR_OICR_ENA_M	MAKEMASK(0xFFFFFFFF,

PF_INT_DIR_OICR_ENA_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 7 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +7 -0
+#define PF_INT_DIR_OICR			0x08406004
+#define PF_INT_DIR_OICR_TSYN_EVNT	0
+#define PF_INT_DIR_OICR_PHY_TS_0	BIT(1)
+#define PF_INT_DIR_OICR_PHY_TS_1	BIT(2)
+#define PF_INT_DIR_OICR_CAUSE		0x08406008
+#define PF_INT_DIR_OICR_CAUSE_CAUSE_S	0
+#define PF_INT_DIR_OICR_CAUSE_CAUSE_M
	MAKEMASK(0xFFFFFFFF, PF_INT_DIR_OICR_CAUSE_CAUSE_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 5 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +5 -0
+#define PF_INT_PBA_CLEAR		0x0840600C
+
+#define PF_FUNC_RID			0x08406010
+#define PF_FUNC_RID_FUNCTION_NUMBER_S	0
+#define PF_FUNC_RID_FUNCTION_NUMBER_M	MAKEMASK(0x7,

PF_FUNC_RID_FUNCTION_NUMBER_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 113

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FUNC_RID_DEVICE_NUMBER_S	3
+#define PF_FUNC_RID_DEVICE_NUMBER_M	MAKEMASK(0x1F,

PF_FUNC_RID_DEVICE_NUMBER_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 115

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PF_FUNC_RID_BUS_NUMBER_S	8
+#define PF_FUNC_RID_BUS_NUMBER_M	MAKEMASK(0xFF,

PF_FUNC_RID_BUS_NUMBER_S)

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

Quoted 10 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +10 -0
+
+/* Reset registers */
+#define PFGEN_RTRIG			0x08407000
+#define PFGEN_RTRIG_CORER_S		0
+#define PFGEN_RTRIG_CORER_M		BIT(0)
+#define PFGEN_RTRIG_LINKR_S		1
+#define PFGEN_RTRIG_LINKR_M		BIT(1)
+#define PFGEN_RTRIG_IMCR_S		2
+#define PFGEN_RTRIG_IMCR_M		BIT(2)
+#define PFGEN_RSTAT			0x08407008 /* PFR Status

*/

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h line 127

Quoted 2 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +2 -0
+#define PFGEN_RSTAT_PFR_STATE_S		0
+#define PFGEN_RSTAT_PFR_STATE_M		MAKEMASK(0x3,

PFGEN_RSTAT_PFR_STATE_S)

Quoted 6 lines
drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h new file +4 -1
+#define PFGEN_CTRL			0x0840700C
+#define PFGEN_CTRL_PFSWR		BIT(0)
+
+#endif
--

2.33.0

Thanks,
Al

#81 lore raw

PATCH 19/19 idpf: introduce idpf driver

From: Alan Brady <[email protected]>
Date: Thu, 3 Feb 2022 04:07:10 +0100

Quoted 28 lines
Quoted 18 lines

-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, January 28, 2022 12:08 PM
To: Brady, Alan <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; intel-wired- lan at lists.osuosl.org; Burra, Phani R <[email protected]>; Chittim, Madhu <[email protected]>; Linga, Pavan Kumar <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 19/19] idpf: introduce idpf driver

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:10:09 -0800

Quoted 3 lines

This adds the idpf driver which uses the iecm module to provide common functionality. Device specific behavior and registers are defined here and handed off to iecm which takes over the rest of the flow.

Quoted 9 lines

Ok I missed that before, so I say it now.
Multi-function networking devices (Ethernet, SFs, VF representors, RDMA, storage offload etc.) nowadays kinda *must* be based on top of auxiliary bus. Otherwise, maintaining of hundreds a direct call with recursive dependencies between modules and stuff will become a burden.
All of the mentioned functionality will be added to the driver(s), that's a fact, and as these are new drivers, it's way better to start off the right way now than to bug your mind on how to refactor this later.

Quoted 1 line

I suspect a refactor now will actually be more painful than later for other reasons and I believe we have other motivations for not using aux bus in this. It is however worth considering but we need some time to discuss. Will reply with something firm after some internal discussion.

The earlier the easier, it's always more difficult to remodel stuff later than during the initial preparation. It then will start absorb changes from both the community and a pool of Intel employees, iecm/idpf maintainers will have to support the accepted in-tree driver along with the internal dev tree, and nothing from those eases any core changes.
I heard the phrase "we have a motivation" several times, but nobody explained it to me yet (thus I'm kindly asking for this once again), so I speak only from the development and feature-richness perspective.

Quoted 16 lines
Quoted 16 lines
Quoted 7 lines
Quoted 8 lines
---
 .../device_drivers/ethernet/intel/idpf.rst    |  47 ++++++
 drivers/net/ethernet/intel/Kconfig            |  16 ++
 drivers/net/ethernet/intel/Makefile           |   1 +
 drivers/net/ethernet/intel/idpf/Makefile      |  15 ++
 drivers/net/ethernet/intel/idpf/idpf_dev.h    |  17 +++
 drivers/net/ethernet/intel/idpf/idpf_devids.h |  10 ++
 drivers/net/ethernet/intel/idpf/idpf_main.c   | 140

++++++++++++++++++

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
 drivers/net/ethernet/intel/idpf/idpf_reg.c    | 130 ++++++++++++++++
 .../ethernet/intel/include/iecm_lan_pf_regs.h | 131 ++++++++++++++++
 9 files changed, 507 insertions(+)
 create mode 100644

Documentation/networking/device_drivers/ethernet/intel/idpf.rst

Quoted 8 lines
Quoted 8 lines
 create mode 100644 drivers/net/ethernet/intel/idpf/Makefile
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c
 create mode 100644 drivers/net/ethernet/intel/idpf/idpf_reg.c
 create mode 100644

drivers/net/ethernet/intel/include/iecm_lan_pf_regs.h

--- 8< ---

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

--
2.33.0

Thanks,
Al

Al

#82 lore raw

cover Add iecm and idpf

In reply to Alan Brady

From: Alan Brady <[email protected]>
Date: Thu, 27 Jan 2022 16:09:50 -0800

Quoted 9 lines

This series introduces both the Intel Ethernet Common Module and the Intel Data Plane Function. This also adds extended features and functionality to virtchnl with virtchnl_2.h.

The format of the series generally follows the flow of driver init to interface open. We go from probe into a hard reset followed by an init task. From there the rest of the netdev_ops and data path are added. Then lastly advanced features and idpf are introduced.

Quoted 5 lines

Currently this common layer (iecm) is initially only being used by only the idpf driver (PF driver for SmartNIC). However, the plan is to eventually switch our iavf driver along with future drivers to use this common module. The hope is to better enable code sharing going forward as well as support other developers writing drivers for our hardware

                                                                      ^

There's a dot '.' missing.

Quoted 20 lines

Alan Brady (17):
virtchnl: Add new virtchnl2 ops
iecm: add basic module init and documentation
iecm: add probe and remove
iecm: add api_init and controlq init
iecm: add vport alloc and virtchnl messages
iecm: add virtchnl messages for queues
iecm: finish virtchnl messages
iecm: add interrupts and configure netdev
iecm: alloc vport TX resources
iecm: alloc vport RX resources
iecm: add start_xmit and set_rx_mode
iecm: finish netdev_ops
iecm: implement splitq napi_poll
iecm: implement singleq napi_poll
iecm: implement ethtool callbacks
iecm: implement cloud filters
idpf: introduce idpf driver

Quoted 3 lines

Haiyue Wang (2):
iecm: implement flow director
iecm: add advanced rss

I'd like to remind here that you can *not* proceed with publishing a v2 to netdev ML before at least me *and* Shannon (we're the only two for now who did reviews here) say "I'm okay with your vN revision".
I'm doing this because this is what you did previously, transferring from our internal ML to IWL. In fact, you changed a bunch of code and the authorship of two patches, but didn't publish a v2 there and went directly here instead, without even providing a changelog, so I only realized there were other changes apart from the authors only when started comparing those two submissions. Incorporating only the changes marked by you as "will fix" and not getting the others resolved (places you didn't explain or answer to, questionable "won't fix" which the reviewers disagree with etc.) doesn't make this series ready for netdev ML.
And please supply changelogs at the end of the cover letter for each subsequent revision, so people could easily see what was addressed and what was not.

Quoted 22 lines
 .../device_drivers/ethernet/intel/idpf.rst    |   47 +
 .../device_drivers/ethernet/intel/iecm.rst    |   93 +
 MAINTAINERS                                   |    1 +
 drivers/net/ethernet/intel/Kconfig            |   31 +
 drivers/net/ethernet/intel/Makefile           |    2 +
 drivers/net/ethernet/intel/idpf/Makefile      |   15 +
 drivers/net/ethernet/intel/idpf/idpf_dev.h    |   17 +
 drivers/net/ethernet/intel/idpf/idpf_devids.h |   10 +
 drivers/net/ethernet/intel/idpf/idpf_main.c   |  140 +
 drivers/net/ethernet/intel/idpf/idpf_reg.c    |  130 +
 drivers/net/ethernet/intel/iecm/Makefile      |   21 +
 .../net/ethernet/intel/iecm/iecm_controlq.c   |  649 ++
 .../ethernet/intel/iecm/iecm_controlq_setup.c |  175 +
 .../net/ethernet/intel/iecm/iecm_ethtool.c    | 1332 ++++
 drivers/net/ethernet/intel/iecm/iecm_lib.c    | 5717 +++++++++++++++++
 drivers/net/ethernet/intel/iecm/iecm_main.c   |   40 +
 .../ethernet/intel/iecm/iecm_singleq_txrx.c   | 1229 ++++
 drivers/net/ethernet/intel/iecm/iecm_txrx.c   | 4577 +++++++++++++
 .../net/ethernet/intel/iecm/iecm_virtchnl.c   | 4240 ++++++++++++
 drivers/net/ethernet/intel/include/iecm.h     |  973 +++
 .../ethernet/intel/include/iecm_controlq.h    |  117 +
Quoted 8 lines
 .../intel/include/iecm_controlq_api.h         |  185 +
 .../ethernet/intel/include/iecm_lan_pf_regs.h |  131 +
 .../ethernet/intel/include/iecm_lan_txrx.h    |  394 ++
 drivers/net/ethernet/intel/include/iecm_mem.h |   20 +
 .../net/ethernet/intel/include/iecm_txrx.h    |  733 +++
 include/linux/avf/virtchnl.h                  | 1507 ++++-
 include/linux/avf/virtchnl_2.h                | 1243 ++++
 include/linux/avf/virtchnl_lan_desc.h         |  603 ++

--- 8< ---

Quoted 2 lines
Signature · 1 line
2.33.0

Thanks,
Al