Skip to contentSkip to conversation

share code update.

PATCH Superseded Qi Zhang 6 participants 168 messages Feb 28, 2019 – Apr 1, 2019 Page 1 of 2

Subsystems (2)
lore
Share & tools
lore

Qi Zhang

author
#0 lore raw

cover share code update.

Main changes:
1. add DCB/FDIR support.
2. add more APIs in switch module.
3. code clean and bug fix.

Qi Zhang (37):
net/ice/base: add switch resource allocation and free net/ice/base: improve comments
net/ice/base: add two helper functions net/ice/base: add helper macros
net/ice/base: allow package copy to be used after resets net/ice/base: code clean
net/ice/base: declare functions as external net/ice/base: add more APIs in switch module net/ice/base: add VSI queue context framework net/ice/base: add APIs to add remove ethertype filter net/ice/base: add APIs to get allocated resources net/ice/base: add APIs to alloc/free VLAN resource counter net/ice/base: add APIs to get VSI promiscuous mode net/ice/base: add MAC filter with marker and counter net/ice/base: add two helper functions for flow management net/ice/base: minor fix
net/ice/base: update macros
net/ice/base: code clean
net/ice/base: enable VSI queue context net/ice/base: ensure only valid bits are set net/ice/base: enhance get link status command net/ice/base: add RSS key related macro and structures net/ice/base: do not write TCAM entries back net/ice/base: remove local VSIG allocations net/ice/base: minor fix
net/ice/base: update copyright time
net/ice/base: resolve static analysis reported issues net/ice/base: return config error without queue to disable net/ice/base: add function to check FW recovery mode net/ice/base: change profile id reference counting net/ice/base: add DCB support
net/ice/base: add FDIR support
net/ice/base: change profile priority for RSS reply net/ice/base: remove duplicate resource allocations net/ice/base: minor fix
net/ice/base: increase prototol offset size net/ice/base: revert the workaround for resource allocation

 drivers/net/ice/Makefile                 |    2 +
 drivers/net/ice/base/ice_adminq_cmd.h    |  515 +++++-
 drivers/net/ice/base/ice_alloc.h         |    2 +-
 drivers/net/ice/base/ice_common.c        |  650 ++++++--
 drivers/net/ice/base/ice_common.h        |   36 +-
 drivers/net/ice/base/ice_controlq.c      |   10 +-
 drivers/net/ice/base/ice_controlq.h      |    2 +-
 drivers/net/ice/base/ice_dcb.c           | 1393 ++++++++++++++++
 drivers/net/ice/base/ice_dcb.h           |  223 +++
 drivers/net/ice/base/ice_devids.h        |    2 +-
 drivers/net/ice/base/ice_fdir.c          |  742 +++++++++
 drivers/net/ice/base/ice_fdir.h          |  205 +++
 drivers/net/ice/base/ice_flex_pipe.c     | 1075 +++++++------
 drivers/net/ice/base/ice_flex_pipe.h     |    4 +-
 drivers/net/ice/base/ice_flex_type.h     |   19 +-
 drivers/net/ice/base/ice_flow.c          |  224 +--
 drivers/net/ice/base/ice_flow.h          |   22 +-
 drivers/net/ice/base/ice_hw_autogen.h    |    2 +-
 drivers/net/ice/base/ice_lan_tx_rx.h     |  149 +-
 drivers/net/ice/base/ice_nvm.c           |   17 +-
 drivers/net/ice/base/ice_osdep.h         |   16 +
 drivers/net/ice/base/ice_protocol_type.h |    8 +-
 drivers/net/ice/base/ice_sbq_cmd.h       |    2 +-
 drivers/net/ice/base/ice_sched.c         | 2563 +++++++++++++++---------------
 drivers/net/ice/base/ice_sched.h         |   34 +-
 drivers/net/ice/base/ice_status.h        |    3 +-
 drivers/net/ice/base/ice_switch.c        | 1315 ++++++++++++++-
 drivers/net/ice/base/ice_switch.h        |  109 +-
 drivers/net/ice/base/ice_type.h          |  119 +-
 drivers/net/ice/base/meson.build         |    2 +
 drivers/net/ice/ice_rxtx.c               |   11 +-
 31 files changed, 7114 insertions(+), 2362 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_dcb.c
 create mode 100644 drivers/net/ice/base/ice_dcb.h
 create mode 100644 drivers/net/ice/base/ice_fdir.c
 create mode 100644 drivers/net/ice/base/ice_fdir.h
Signature · 1 line
2.13.6
author
#1 lore raw

PATCH 1/37 net/ice/base: add switch resource allocation and free

Add two APIs ice_alloc_sw and ice_free_sw to support switch related resource allocation and free.

---
 drivers/net/ice/base/ice_switch.c | 150 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   5 ++
 2 files changed, 155 insertions(+)
drivers/net/ice/base/ice_switch.c +150 -0
index 0379cd045..a7b712e17 100644
@@ -129,6 +129,156 @@ ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp *buf,
 }
 
 
+/**
+ * ice_alloc_sw - allocate resources specific to switch
+ * @hw: pointer to the HW struct
+ * @ena_stats: true to turn on VEB stats
+ * @shared_res: true for shared resource, false for dedicated resource
+ * @sw_id: switch ID returned
+ * @counter_id: VEB counter ID returned
+ *
+ * allocates switch resources (SWID and VEB counter) (0x0208)
+ */
+enum ice_status
+ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
+	     u16 *counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf;
+	struct ice_aqc_res_elem *sw_ele;
+	enum ice_status status;
+	u16 buf_len;
+
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		   ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	/* Prepare buffer for switch ID.
+	 * The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is allocated, and hence a single sw_id
+	 * is requested.
+	 */
+	sw_buf->num_elems = CPU_TO_LE16(1);
+	sw_buf->res_type =
+		CPU_TO_LE16(ICE_AQC_RES_TYPE_SWID |
+			    (shared_res ? ICE_AQC_RES_TYPE_FLAG_SHARED :
+			    ICE_AQC_RES_TYPE_FLAG_DEDICATED));
+
+	status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+
+	if (status)
+		goto ice_alloc_sw_exit;
+
+	sw_ele = &sw_buf->elem[0];
+	*sw_id = LE16_TO_CPU(sw_ele->e.sw_resp);
+
+	if (ena_stats) {
+		/* Prepare buffer for VEB Counter */
+		enum ice_adminq_opc opc = ice_aqc_opc_alloc_res;
+		struct ice_aqc_alloc_free_res_elem *counter_buf;
+		struct ice_aqc_res_elem *counter_ele;
+
+		counter_buf = (struct ice_aqc_alloc_free_res_elem *)
+				ice_malloc(hw, buf_len);
+		if (!counter_buf) {
+			status = ICE_ERR_NO_MEMORY;
+			goto ice_alloc_sw_exit;
+		}
+
+		/* The number of resource entries in buffer is passed as 1 since
+		 * only a single switch/VEB instance is allocated, and hence a
+		 * single VEB counter is requested.
+		 */
+		counter_buf->num_elems = CPU_TO_LE16(1);
+		counter_buf->res_type =
+			CPU_TO_LE16(ICE_AQC_RES_TYPE_VEB_COUNTER |
+				    ICE_AQC_RES_TYPE_FLAG_DEDICATED);
+		status = ice_aq_alloc_free_res(hw, 1, counter_buf, buf_len,
+					       opc, NULL);
+
+		if (status) {
+			ice_free(hw, counter_buf);
+			goto ice_alloc_sw_exit;
+		}
+		counter_ele = &counter_buf->elem[0];
+		*counter_id = LE16_TO_CPU(counter_ele->e.sw_resp);
+		ice_free(hw, counter_buf);
+	}
+
+ice_alloc_sw_exit:
+	ice_free(hw, sw_buf);
+	return status;
+}
+
+/**
+ * ice_free_sw - free resources specific to switch
+ * @hw: pointer to the HW struct
+ * @sw_id: switch ID returned
+ * @counter_id: VEB counter ID returned
+ *
+ * free switch resources (SWID and VEB counter) (0x0209)
+ *
+ * NOTE: This function frees multiple resources. It continues
+ * releasing other resources even after it encounters error.
+ * The error code returned is the last error it encountered.
+ */
+enum ice_status ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf, *counter_buf;
+	enum ice_status status, ret_status;
+	u16 buf_len;
+
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		   ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	/* Prepare buffer to free for switch ID res.
+	 * The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is freed, and hence a single sw_id
+	 * is released.
+	 */
+	sw_buf->num_elems = CPU_TO_LE16(1);
+	sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_SWID);
+	sw_buf->elem[0].e.sw_resp = CPU_TO_LE16(sw_id);
+
+	ret_status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+					   ice_aqc_opc_free_res, NULL);
+
+	if (ret_status)
+		ice_debug(hw, ICE_DBG_SW, "CQ CMD Buffer:\n");
+
+	/* Prepare buffer to free for VEB Counter resource */
+	counter_buf = (struct ice_aqc_alloc_free_res_elem *)
+			ice_malloc(hw, buf_len);
+	if (!counter_buf) {
+		ice_free(hw, sw_buf);
+		return ICE_ERR_NO_MEMORY;
+	}
+
+	/* The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is freed, and hence a single VEB counter
+	 * is released
+	 */
+	counter_buf->num_elems = CPU_TO_LE16(1);
+	counter_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_VEB_COUNTER);
+	counter_buf->elem[0].e.sw_resp = CPU_TO_LE16(counter_id);
+
+	status = ice_aq_alloc_free_res(hw, 1, counter_buf, buf_len,
+				       ice_aqc_opc_free_res, NULL);
+	if (status) {
+		ice_debug(hw, ICE_DBG_SW,
+			  "VEB counter resource could not be freed\n");
+		ret_status = status;
+	}
+
+	ice_free(hw, counter_buf);
+	ice_free(hw, sw_buf);
+	return ret_status;
+}
 
 /**
  * ice_aq_add_vsi
drivers/net/ice/base/ice_switch.h +5 -0
index 66a172fc2..dd21781f7 100644
@@ -290,6 +290,11 @@ ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
 /* Switch/bridge related commands */
 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
 enum ice_status
+ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
+	     u16 *counter_id);
+enum ice_status
+ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id);
+enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
Signature · 1 line
2.13.6
author
#2 lore raw

PATCH 2/37 net/ice/base: improve comments

In reply to Qi Zhang

Improve comments to follow naming rules.
Also the patch include some minor cleanup.

---
 drivers/net/ice/base/ice_adminq_cmd.h    |  27 +-
 drivers/net/ice/base/ice_common.c        | 148 +++----
 drivers/net/ice/base/ice_common.h        |   4 +-
 drivers/net/ice/base/ice_controlq.c      |   8 +-
 drivers/net/ice/base/ice_flex_pipe.c     | 364 ++++++++--------
 drivers/net/ice/base/ice_flex_pipe.h     |   2 +-
 drivers/net/ice/base/ice_flex_type.h     |   4 +-
 drivers/net/ice/base/ice_flow.c          |  65 +--
 drivers/net/ice/base/ice_flow.h          |   1 -
 drivers/net/ice/base/ice_lan_tx_rx.h     |  70 +--
 drivers/net/ice/base/ice_nvm.c           |   8 +-
 drivers/net/ice/base/ice_protocol_type.h |   4 +-
 drivers/net/ice/base/ice_sched.c         | 719 ++++++++++++++++---------------
 drivers/net/ice/base/ice_sched.h         |   8 +-
 drivers/net/ice/base/ice_switch.c        | 120 +++---
 drivers/net/ice/base/ice_switch.h        |  20 +-
 drivers/net/ice/base/ice_type.h          |  34 +-
 17 files changed, 804 insertions(+), 802 deletions(-)
drivers/net/ice/base/ice_adminq_cmd.h +13 -14
index a1b9edd14..5a599280e 100644
@@ -71,7 +71,7 @@ struct ice_aqc_req_res {
 #define ICE_AQ_RES_NVM_WRITE_DFLT_TIMEOUT_MS	180000
 #define ICE_AQ_RES_CHNG_LOCK_DFLT_TIMEOUT_MS	1000
 #define ICE_AQ_RES_GLBL_LOCK_DFLT_TIMEOUT_MS	3000
-	/* For SDP: pin id of the SDP */
+	/* For SDP: pin ID of the SDP */
 	__le32 res_number;
 	/* Status is only used for ICE_AQC_RES_ID_GLBL_LOCK */
 	__le16 status;
@@ -854,7 +854,6 @@ struct ice_aqc_delete_elem {
 
 
 
-
 /* Rate limiting profile for
  * Add RL profile (indirect 0x0410)
  * Query RL profile (indirect 0x0411)
@@ -1154,8 +1153,8 @@ struct ice_aqc_set_phy_cfg_data {
 	__le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */
 	__le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */
 	u8 caps;
-#define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY		BIT(0)
-#define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY		BIT(1)
+#define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY	BIT(0)
+#define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY	BIT(1)
 #define ICE_AQ_PHY_ENA_LOW_POWER	BIT(2)
 #define ICE_AQ_PHY_ENA_LINK		BIT(3)
 #define ICE_AQ_PHY_ENA_AUTO_LINK_UPDT	BIT(5)
@@ -1228,7 +1227,7 @@ struct ice_aqc_get_link_status_data {
 	u8 ext_info;
 #define ICE_AQ_LINK_PHY_TEMP_ALARM	BIT(0)
 #define ICE_AQ_LINK_EXCESSIVE_ERRORS	BIT(1)	/* Excessive Link Errors */
-	/* Port TX Suspended */
+	/* Port Tx Suspended */
 #define ICE_AQ_LINK_TX_S		2
 #define ICE_AQ_LINK_TX_M		(0x03 << ICE_AQ_LINK_TX_S)
 #define ICE_AQ_LINK_TX_ACTIVE		0
@@ -1441,7 +1440,7 @@ struct ice_aqc_get_set_rss_lut {
 
 
 
-/* Add TX LAN Queues (indirect 0x0C30) */
+/* Add Tx LAN Queues (indirect 0x0C30) */
 struct ice_aqc_add_txqs {
 	u8 num_qgrps;
 	u8 reserved[3];
@@ -1451,7 +1450,7 @@ struct ice_aqc_add_txqs {
 };
 
 
-/* This is the descriptor of each queue entry for the Add TX LAN Queues
+/* This is the descriptor of each queue entry for the Add Tx LAN Queues
  * command (0x0C30). Only used within struct ice_aqc_add_tx_qgrp.
  */
 struct ice_aqc_add_txqs_perq {
@@ -1464,7 +1463,7 @@ struct ice_aqc_add_txqs_perq {
 };
 
 
-/* The format of the command buffer for Add TX LAN Queues (0x0C30)
+/* The format of the command buffer for Add Tx LAN Queues (0x0C30)
  * is an array of the following structs. Please note that the length of
  * each struct ice_aqc_add_tx_qgrp is variable due
  * to the variable number of queues in each group!
@@ -1477,7 +1476,7 @@ struct ice_aqc_add_tx_qgrp {
 };
 
 
-/* Disable TX LAN Queues (indirect 0x0C31) */
+/* Disable Tx LAN Queues (indirect 0x0C31) */
 struct ice_aqc_dis_txqs {
 	u8 cmd_type;
 #define ICE_AQC_Q_DIS_CMD_S		0
@@ -1500,7 +1499,7 @@ struct ice_aqc_dis_txqs {
 };
 
 
-/* The buffer for Disable TX LAN Queues (indirect 0x0C31)
+/* The buffer for Disable Tx LAN Queues (indirect 0x0C31)
  * contains the following structures, arrayed one after the
  * other.
  * Note: Since the q_id is 16 bits wide, if the
@@ -1528,7 +1527,7 @@ struct ice_aqc_dis_txq {
 };
 
 
-/* TX LAN Queues Cleanup Event (0x0C31) */
+/* Tx LAN Queues Cleanup Event (0x0C31) */
 struct ice_aqc_txqs_cleanup {
 	__le16 caller_opc;
 	__le16 cmd_tag;
@@ -1536,7 +1535,7 @@ struct ice_aqc_txqs_cleanup {
 };
 
 
-/* Move / Reconfigure TX Queues (indirect 0x0C32) */
+/* Move / Reconfigure Tx Queues (indirect 0x0C32) */
 struct ice_aqc_move_txqs {
 	u8 cmd_type;
 #define ICE_AQC_Q_CMD_TYPE_S		0
@@ -1557,7 +1556,7 @@ struct ice_aqc_move_txqs {
 };
 
 
-/* This is the descriptor of each queue entry for the move TX LAN Queues
+/* This is the descriptor of each queue entry for the move Tx LAN Queues
  * command (0x0C32).
  */
 struct ice_aqc_move_txqs_elem {
@@ -1950,7 +1949,7 @@ enum ice_adminq_opc {
 	ice_aqc_opc_get_rss_key				= 0x0B04,
 	ice_aqc_opc_get_rss_lut				= 0x0B05,
 
-	/* TX queue handling commands/events */
+	/* Tx queue handling commands/events */
 	ice_aqc_opc_add_txqs				= 0x0C30,
 	ice_aqc_opc_dis_txqs				= 0x0C31,
 	ice_aqc_opc_txqs_cleanup			= 0x0C31,
drivers/net/ice/base/ice_common.c +74 -74

516 lines not on this page · raw message

drivers/net/ice/base/ice_common.h +1 -3
index 5ac991ef2..f2ad86182 100644
@@ -61,8 +61,7 @@ enum ice_status ice_get_caps(struct ice_hw *hw);
  * ... the value of pointer would equal 0x1008, since 0x1008 is the next
  * address after 0x1006 which is divisible by 4.
  */
-#define ICE_ALIGN(ptr, align)   (((ptr) + ((align) - 1)) & ~((align) - 1))
-
+#define ICE_ALIGN(ptr, align)	(((ptr) + ((align) - 1)) & ~((align) - 1))
 
 enum ice_status
 ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,
@@ -149,7 +148,6 @@ ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 
 
 
-
 enum ice_status
 ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
drivers/net/ice/base/ice_controlq.c +4 -4
index cbc4cb4c2..1c0830cec 100644
@@ -54,7 +54,7 @@ static void ice_mailbox_init_regs(struct ice_hw *hw)
 
 /**
  * ice_check_sq_alive
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  *
  * Returns true if Queue is enabled else false.
@@ -729,7 +729,7 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 
 /**
  * ice_sq_done - check if FW has processed the Admin Send Queue (ATQ)
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  *
  * Returns true if the firmware has processed all descriptors on the
@@ -745,7 +745,7 @@ static bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 
 /**
  * ice_sq_send_cmd - send command to Control Queue (ATQ)
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  * @desc: prefilled descriptor describing the command (non DMA mem)
  * @buf: buffer to use for indirect commands (or NULL for direct commands)
@@ -990,7 +990,7 @@ void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode)
 
 /**
  * ice_clean_rq_elem
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  * @e: event info from the receive descriptor, includes any buffers
  * @pending: number of events that could be left to process
drivers/net/ice/base/ice_flex_pipe.c +182 -182

999 lines not on this page · raw message

drivers/net/ice/base/ice_flex_pipe.h +1 -1
index 81e89aeeb..23fffed75 100644
@@ -59,7 +59,7 @@ void ice_ptg_free(struct ice_hw *hw, enum ice_block blk, u8 ptg);
 enum ice_status
 ice_ptg_add_mv_ptype(struct ice_hw *hw, enum ice_block blk, u16 ptype, u8 ptg);
 
-/* XLT2/Vsi group functions */
+/* XLT2/VSI group functions */
 enum ice_status ice_vsig_update_xlt2(struct ice_hw *hw, enum ice_block blk);
 enum ice_status
 ice_vsig_find_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 *vsig);
drivers/net/ice/base/ice_flex_type.h +2 -2
index 9f98f4f2a..aed23a067 100644
@@ -350,7 +350,7 @@ struct ice_sw_fv_list_entry {
 };
 
 #pragma pack(1)
-/* The BOOST tcam stores the match packet header in reverse order, meaning
+/* The BOOST TCAM stores the match packet header in reverse order, meaning
  * the fields are reversed; in addition, this means that the normally big endian
  * fields of the packet are now little endian.
  */
@@ -602,7 +602,7 @@ struct ice_xlt2 {
 };
 
 /* Extraction sequence - list of match fields:
- * protocol id, offset, profile length
+ * protocol ID, offset, profile length
  */
 union ice_match_fld {
 	struct {
drivers/net/ice/base/ice_flow.c +34 -31

231 lines not on this page · raw message

drivers/net/ice/base/ice_flow.h +0 -1
index 51d7c3ac9..265e1ee3e 100644
@@ -227,7 +227,6 @@ struct ice_flow_entry {
 	u64 id;
 	u16 vsi_handle;
 	enum ice_flow_priority priority;
-
 	struct ice_flow_prof *prof;
 
 	/* Flow entry's content */
drivers/net/ice/base/ice_lan_tx_rx.h +35 -35

170 lines not on this page · raw message

drivers/net/ice/base/ice_nvm.c +4 -4
index 25a2ca4cb..92de2ec3b 100644
@@ -7,7 +7,7 @@
 
 /**
  * ice_aq_read_nvm
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @module_typeid: module pointer location in words from the NVM beginning
  * @offset: byte offset from the module beginning
  * @length: length of the section to be read (in bytes from the offset)
@@ -248,7 +248,7 @@ enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data)
 
 /**
  * ice_init_nvm - initializes NVM setting
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  *
  * This function reads and populates NVM settings such as Shadow RAM size,
  * max_timeout, and blank_nvm_mode
@@ -264,7 +264,7 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)
 
 	ice_debug(hw, ICE_DBG_TRACE, "ice_init_nvm");
 
-	/* The SR size is stored regardless of the nvm programming mode
+	/* The SR size is stored regardless of the NVM programming mode
 	 * as the blank mode may be used in the factory line.
 	 */
 	gens_stat = rd32(hw, GLNVM_GENS);
@@ -357,7 +357,7 @@ ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
 
 /**
  * ice_nvm_validate_checksum
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  *
  * Verify NVM PFA checksum validity (0x0706)
  */
drivers/net/ice/base/ice_protocol_type.h +2 -2
index 7b92c7105..f96964d86 100644
@@ -18,7 +18,7 @@
 /* Max recipes that can be chained */
 #define ICE_MAX_CHAIN_RECIPE 5
 
-/* 1 word reserved for switch id from allowed 5 words.
+/* 1 word reserved for switch ID from allowed 5 words.
  * So a recipe can have max 4 words. And you can chain 5 such recipes
  * together. So maximum words that can be programmed for look up is 5 * 4.
  */
@@ -128,7 +128,7 @@ enum ice_prot_id {
 
 #define ICE_PROTOCOL_MAX_ENTRIES 16
 
-/* Mapping of software defined protocol id to hardware defined protocol id */
+/* Mapping of software defined protocol ID to hardware defined protocol ID */
 struct ice_protocol_entry {
 	enum ice_protocol_type type;
 	u8 protocol_id;
drivers/net/ice/base/ice_sched.c +360 -359

852 lines not on this page · raw message

drivers/net/ice/base/ice_sched.h +4 -4
index a5565945e..61fa6a85b 100644

Lines of this file are not shown. View the raw message.

drivers/net/ice/base/ice_switch.c +60 -60

120 lines not on this page · raw message

drivers/net/ice/base/ice_switch.h +11 -9
index dd21781f7..90dfdabcb 100644

Lines of this file are not shown. View the raw message.

drivers/net/ice/base/ice_type.h +17 -17
index 17d79ba21..08c974004 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.13.6

Part of the diff is not shown here. View the raw message.

author
#3 lore raw

PATCH 3/37 net/ice/base: add two helper functions

In reply to Qi Zhang

Add two helper functions in common module.
1. ice_aq_set_mac_cfg to help configure maximum frame size with AQ command
2. ice_get_ctx help to extract context bits from a packet structure.

---
 drivers/net/ice/base/ice_adminq_cmd.h |  20 +++
 drivers/net/ice/base/ice_common.c     | 282 ++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_common.h     |   4 +
 3 files changed, 306 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +20 -0
index 5a599280e..feb980475 100644
@@ -1168,6 +1168,25 @@ struct ice_aqc_set_phy_cfg_data {
 };
 
 
+/* Set MAC Config command data structure (direct 0x0603) */
+struct ice_aqc_set_mac_cfg {
+	__le16 max_frame_size;
+	u8 params;
+#define ICE_AQ_SET_MAC_PACE_S		3
+#define ICE_AQ_SET_MAC_PACE_M		(0xF << ICE_AQ_SET_MAC_PACE_S)
+#define ICE_AQ_SET_MAC_PACE_TYPE_M	BIT(7)
+#define ICE_AQ_SET_MAC_PACE_TYPE_RATE	0
+#define ICE_AQ_SET_MAC_PACE_TYPE_FIXED	ICE_AQ_SET_MAC_PACE_TYPE_M
+	u8 tx_tmr_priority;
+	__le16 tx_tmr_value;
+	__le16 fc_refresh_threshold;
+	u8 drop_opts;
+#define ICE_AQ_SET_MAC_AUTO_DROP_MASK		BIT(0)
+#define ICE_AQ_SET_MAC_AUTO_DROP_NONE		0
+#define ICE_AQ_SET_MAC_AUTO_DROP_BLOCKING_PKTS	BIT(0)
+	u8 reserved[7];
+};
+
 
 /* Restart AN command data structure (direct 0x0605)
  * Also used for response, with only the lport_num field present.
@@ -1782,6 +1801,7 @@ struct ice_aq_desc {
 		struct ice_aqc_get_clear_fw_log get_clear_fw_log;
 		struct ice_aqc_set_mac_lb set_mac_lb;
 		struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
+		struct ice_aqc_set_mac_cfg set_mac_cfg;
 		struct ice_aqc_set_event_mask set_event_mask;
 		struct ice_aqc_get_link_status get_link_status;
 	} params;
drivers/net/ice/base/ice_common.c +282 -0

294 lines not on this page · raw message

drivers/net/ice/base/ice_common.h +4 -0
index f2ad86182..0b387cdbe 100644
@@ -133,6 +133,8 @@ enum ice_status
 ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
 			   struct ice_sq_cd *cd);
 enum ice_status
+ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd);
+enum ice_status
 ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
 		     struct ice_link_status *link, struct ice_sq_cd *cd);
 enum ice_status
@@ -149,6 +151,8 @@ ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 
 
 enum ice_status
+ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info);
+enum ice_status
 ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
 		struct ice_sq_cd *cmd_details);
Signature · 1 line
2.13.6
author
#4 lore raw

PATCH 4/37 net/ice/base: add helper macros

In reply to Qi Zhang

1. Add macro ice_for_each_traffic_class to loop for each traffic class.
2. Add macro MIN_T to wrap min with type conversion.

---
 drivers/net/ice/base/ice_common.c |  2 +-
 drivers/net/ice/base/ice_nvm.c    |  7 ++++---
 drivers/net/ice/base/ice_sched.c  | 30 +++++++++++++++---------------
 drivers/net/ice/base/ice_type.h   |  7 +++++++
 4 files changed, 27 insertions(+), 19 deletions(-)
drivers/net/ice/base/ice_common.c +1 -1
index 392183375..86d3be17a 100644
@@ -3669,7 +3669,7 @@ ice_cfg_vsi_qs(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
 
 	ice_acquire_lock(&pi->sched_lock);
 
-	for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
+	ice_for_each_traffic_class(i) {
 		/* configuration is possible only if TC node is present */
 		if (!ice_sched_get_tc_node(pi, i))
 			continue;
drivers/net/ice/base/ice_nvm.c +4 -3
index 92de2ec3b..8d3d0b0ed 100644
@@ -163,9 +163,10 @@ ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
 		 */
 		off_w = offset % ICE_SR_SECTOR_SIZE_IN_WORDS;
 		read_size = off_w ?
-			min(*words,
-			    (u16)(ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
-			min((*words - words_read), ICE_SR_SECTOR_SIZE_IN_WORDS);
+			MIN_T(u16, *words,
+			      (ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
+			MIN_T(u16, (*words - words_read),
+			      ICE_SR_SECTOR_SIZE_IN_WORDS);
 
 		/* Check if this is last command, if so set proper flag */
 		if ((words_read + read_size) >= *words)
drivers/net/ice/base/ice_sched.c +15 -15
index 2edc305b5..237bf7350 100644
@@ -1896,7 +1896,7 @@ ice_sched_rm_vsi_cfg(struct ice_port_info *pi, u16 vsi_handle, u8 owner)
 	if (!vsi_ctx)
 		goto exit_sched_rm_vsi_cfg;
 
-	for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
+	ice_for_each_traffic_class(i) {
 		struct ice_sched_node *vsi_node, *tc_node;
 		u8 j = 0;
 
@@ -2174,7 +2174,7 @@ ice_sched_cfg_agg(struct ice_port_info *pi, u32 agg_id,
 		LIST_ADD(&agg_info->list_entry, &hw->agg_list);
 	}
 	/* Create aggregator node(s) for requested TC(s) */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_tc_ena(*tc_bitmap, tc)) {
 			/* Delete aggregator cfg TC if it exists previously */
 			status = ice_rm_agg_cfg_tc(pi, agg_info, tc, false);
@@ -2340,7 +2340,7 @@ ice_sched_assoc_vsi_to_agg(struct ice_port_info *pi, u32 agg_id,
 		LIST_ADD(&agg_vsi_info->list_entry, &agg_info->agg_vsi_list);
 	}
 	/* Move VSI node to new aggregator node for requested TC(s) */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_tc_ena(*tc_bitmap, tc))
 			continue;
 
@@ -2410,7 +2410,7 @@ enum ice_status ice_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id)
 		goto exit_ice_rm_agg_cfg;
 	}
 
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		status = ice_rm_agg_cfg_tc(pi, agg_info, tc, true);
 		if (status)
 			goto exit_ice_rm_agg_cfg;
@@ -3050,7 +3050,7 @@ ice_cfg_vsi_bw_alloc(struct ice_port_info *pi, u16 vsi_handle, u8 ena_tcmap,
 	ice_acquire_lock(&pi->sched_lock);
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *vsi_node;
 
 		if (!ice_is_tc_ena(ena_tcmap, tc))
@@ -3112,7 +3112,7 @@ ice_cfg_agg_bw_alloc(struct ice_port_info *pi, u32 agg_id, u8 ena_tcmap,
 	}
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *agg_node;
 
 		if (!ice_is_tc_ena(ena_tcmap, tc))
@@ -4174,7 +4174,7 @@ ice_sched_set_agg_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle)
 	if (!vsi_ctx)
 		return ICE_ERR_PARAM;
 
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *node;
 
 		node = vsi_ctx->sched.ag_node[tc];
@@ -4324,7 +4324,7 @@ ice_sched_validate_vsi_srl_node(struct ice_port_info *pi, u16 vsi_handle)
 		return ICE_ERR_PARAM;
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *vsi_node;
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 		enum ice_status status;
@@ -4384,7 +4384,7 @@ ice_sched_set_vsi_bw_shared_lmt(struct ice_port_info *pi, u16 vsi_handle,
 	if (status)
 		goto exit_set_vsi_bw_shared_lmt;
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *vsi_node;
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 
@@ -4442,7 +4442,7 @@ ice_sched_validate_agg_srl_node(struct ice_port_info *pi, u32 agg_id)
 	if (!agg_id_present)
 		return ICE_ERR_PARAM;
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *agg_node;
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 
@@ -4513,7 +4513,7 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
 	}
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 		struct ice_sched_node *tc_node, *agg_node;
 
@@ -5119,7 +5119,7 @@ ice_sched_replay_agg_bw(struct ice_hw *hw, struct ice_sched_agg_info *agg_info)
 
 	if (!agg_info)
 		return ICE_ERR_PARAM;
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_any_bit_set(agg_info->bw_t_info[tc].bw_t_bitmap,
 					ICE_BW_TYPE_CNT))
 			continue;
@@ -5159,7 +5159,7 @@ ice_sched_get_ena_tc_bitmap(struct ice_port_info *pi, ice_bitmap_t *tc_bitmap,
 	u8 tc;
 
 	/* Some TC(s) may be missing after reset, adjust for replay */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++)
+	ice_for_each_traffic_class(tc)
 		if (ice_is_tc_ena(*tc_bitmap, tc) &&
 		    (ice_sched_get_tc_node(pi, tc)))
 			ice_set_bit(tc, ena_tc_bitmap);
@@ -5253,7 +5253,7 @@ ice_sched_replay_tc_node_bw(struct ice_hw *hw)
 	u8 tc;
 
 	ice_acquire_lock(&pi->sched_lock);
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node;
 
 		tc_node = ice_sched_get_tc_node(hw->port_info, tc);
@@ -5291,7 +5291,7 @@ ice_sched_replay_vsi_bw(struct ice_hw *hw, u16 vsi_handle,
 	vsi_ctx = ice_get_vsi_ctx(pi->hw, vsi_handle);
 	if (!vsi_ctx)
 		return ICE_ERR_PARAM;
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_tc_ena(*tc_bitmap, tc))
 			continue;
 		tc_node = ice_sched_get_tc_node(pi, tc);
drivers/net/ice/base/ice_type.h +7 -0
index 08c974004..2e865a78f 100644
@@ -18,6 +18,9 @@
 #define ICE_BYTES_PER_DWORD	4
 #define ICE_MAX_TRAFFIC_CLASS	8
 
+#ifndef MIN_T
+#define MIN_T(_t, _a, _b)	min((_t)(_a), (_t)(_b))
+#endif
 
 #include "ice_status.h"
 #include "ice_hw_autogen.h"
@@ -379,6 +382,10 @@ struct ice_nvm_info {
 
 /* Max number of port to queue branches w.r.t topology */
 #define ICE_TXSCHED_MAX_BRANCHES ICE_MAX_TRAFFIC_CLASS
+
+#define ice_for_each_traffic_class(_i)	\
+	for ((_i) = 0; (_i) < ICE_MAX_TRAFFIC_CLASS; (_i)++)
+
 /* ICE_DFLT_AGG_ID means that all new VM(s)/VSI node connects
  * to driver defined policy for default aggregator
  */
Signature · 1 line
2.13.6
author
#5 lore raw

PATCH 5/37 net/ice/base: allow package copy to be used after resets

In reply to Qi Zhang

For components that make a copy of an external pipeline package file (i.e. the Linux and FreeBSD drivers), save the size of the package file along with the copy so that both can be used when calling ice_init_pkg() after a CORER/GLOBR reset. Also, do not free the copy of the package file in ice_init_pkg() since it is needed afterward for subsequent resets.

---
 drivers/net/ice/base/ice_flex_pipe.c | 9 +++++----
 drivers/net/ice/base/ice_type.h      | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +5 -4
index c87424601..66c47abda 100644
@@ -1269,6 +1269,7 @@ void ice_free_seg(struct ice_hw *hw)
 	if (hw->pkg_copy) {
 		ice_free(hw, hw->pkg_copy);
 		hw->pkg_copy = NULL;
+		hw->pkg_size = 0;
 	}
 	hw->seg = NULL;
 }
@@ -1351,8 +1352,6 @@ static enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
 		status = ICE_SUCCESS;
 	}
 
-	/* Free a previous segment, if necessary */
-	ice_free_seg(hw);
 	if (!status) {
 		hw->seg = seg;
 		/* on successful package download, update other required
@@ -1401,12 +1400,14 @@ enum ice_status ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len)
 	buf_copy = (u8 *)ice_memdup(hw, buf, len, ICE_NONDMA_TO_NONDMA);
 
 	status = ice_init_pkg(hw, buf_copy, len);
-	if (status)
+	if (status) {
 		/* Free the copy, since we failed to initialize the package */
 		ice_free(hw, buf_copy);
-	else
+	} else {
 		/* Track the copied pkg so we can free it later */
 		hw->pkg_copy = buf_copy;
+		hw->pkg_size = len;
+	}
 
 	return status;
 }
drivers/net/ice/base/ice_type.h +1 -0
index 2e865a78f..6bd73ed04 100644
@@ -728,6 +728,7 @@ struct ice_hw {
 
 	/* Pointer to allocated copy of pkg memory */
 	u8 *pkg_copy;
+	u32 pkg_size;
 
 	/* tunneling info */
 	struct ice_tunnel_table tnl;
Signature · 1 line
2.13.6
author
#6 lore raw

PATCH 6/37 net/ice/base: code clean

In reply to Qi Zhang

Remove unnecessary macro and data structure.

---
 drivers/net/ice/base/ice_adminq_cmd.h |   2 -
 drivers/net/ice/base/ice_flex_pipe.c  |   2 -
 drivers/net/ice/base/ice_flow.c       | 136 ----------------------------------
 drivers/net/ice/base/ice_type.h       |   6 --
 4 files changed, 146 deletions(-)
drivers/net/ice/base/ice_adminq_cmd.h +0 -2
index feb980475..056a9fbef 100644
@@ -1930,8 +1930,6 @@ enum ice_adminq_opc {
 	ice_aqc_opc_move_sched_elems			= 0x0408,
 	ice_aqc_opc_suspend_sched_elems			= 0x0409,
 	ice_aqc_opc_resume_sched_elems			= 0x040A,
-	ice_aqc_opc_suspend_sched_traffic		= 0x040B,
-	ice_aqc_opc_resume_sched_traffic		= 0x040C,
 	ice_aqc_opc_delete_sched_elems			= 0x040F,
 	ice_aqc_opc_add_rl_profiles			= 0x0410,
 	ice_aqc_opc_query_rl_profiles			= 0x0411,
drivers/net/ice/base/ice_flex_pipe.c +0 -2
index 66c47abda..2d23c36eb 100644
@@ -2247,8 +2247,6 @@ ice_find_dup_props_vsig(struct ice_hw *hw, enum ice_block blk,
 	for (i = 0; i < xlt2->count; i++) {
 		if (xlt2->vsig_tbl[i].in_use &&
 		    ice_match_prop_lst(chs, &xlt2->vsig_tbl[i].prop_lst)) {
-			*vsig = (i | ((hw->pf_id << ICE_PF_NUM_S) &
-				      ICE_PF_NUM_M));
 			*vsig = ICE_VSIG_VALUE(i, hw->pf_id);
 			return ICE_SUCCESS;
 		}
drivers/net/ice/base/ice_flow.c +0 -136

142 lines not on this page · raw message

drivers/net/ice/base/ice_type.h +0 -6
index 6bd73ed04..25d64477f 100644
@@ -733,12 +733,6 @@ struct ice_hw {
 	/* tunneling info */
 	struct ice_tunnel_table tnl;
 
-	/* PTYPE group and XLT1 management */
-#define ICE_MAX_PTGS	256
-	struct ice_ptg_entry ptg_tbl[ICE_BLK_COUNT][ICE_MAX_PTGS];
-
-#define ICE_XLT1_CNT	1024
-	struct ice_ptg_ptype xlt1_tbl[ICE_BLK_COUNT][ICE_XLT1_CNT];
 #define ICE_PKG_FILENAME	"package_file"
 #define ICE_PKG_FILENAME_EXT	"pkg"
 #define ICE_PKG_FILE_MAJ_VER	1
Signature · 1 line
2.13.6
author
#7 lore raw

PATCH 7/37 net/ice/base: declare functions as external

In reply to Qi Zhang

Remove static of below functions and declare them as external APIs.

ice_aq_add_vsi
ice_aq_free_vsi
ice_aq_update_vsi
ice_aq_add_lan_txq
ice_init_pkg

---
 drivers/net/ice/base/ice_common.c    | 2 +-
 drivers/net/ice/base/ice_common.h    | 4 ++++
 drivers/net/ice/base/ice_flex_pipe.c | 2 +-
 drivers/net/ice/base/ice_flex_pipe.h | 2 ++
 drivers/net/ice/base/ice_switch.c    | 6 +++---
 drivers/net/ice/base/ice_switch.h    | 9 +++++++++
 6 files changed, 20 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_common.c +1 -1
index 86d3be17a..015db11e0 100644
@@ -2935,7 +2935,7 @@ ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
  * Association of Tx queue to Doorbell queue is not part of Add LAN Tx queue
  * flow.
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_lan_txq(struct ice_hw *hw, u8 num_qgrps,
 		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
 		   struct ice_sq_cd *cd)
drivers/net/ice/base/ice_common.h +4 -0
index 0b387cdbe..63f4a5ebe 100644
@@ -94,6 +94,10 @@ ice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
 enum ice_status
 ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
 		   struct ice_aqc_get_set_rss_keys *keys);
+enum ice_status
+ice_aq_add_lan_txq(struct ice_hw *hw, u8 count,
+		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
+		   struct ice_sq_cd *cd);
 
 bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq);
 enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);
drivers/net/ice/base/ice_flex_pipe.c +1 -1
index 2d23c36eb..ff615f94f 100644
@@ -1314,7 +1314,7 @@ static void ice_init_pkg_regs(struct ice_hw *hw)
  * ice_copy_and_init_pkg() instead of directly calling ice_init_pkg() in this
  * case.
  */
-static enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
+enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
 {
 	struct ice_pkg_hdr *pkg;
 	enum ice_status status;
drivers/net/ice/base/ice_flex_pipe.h +2 -0
index 23fffed75..00c2b6682 100644
@@ -88,6 +88,8 @@ ice_set_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 cntxt);
 struct ice_prof_map *
 ice_get_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 *cntxt);
 enum ice_status
+ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len);
+enum ice_status
 ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
 enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
 void ice_free_seg(struct ice_hw *hw);
drivers/net/ice/base/ice_switch.c +3 -3
index 512e64b91..e6fc9fcee 100644
@@ -288,7 +288,7 @@ enum ice_status ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id)
  *
  * Add a VSI context to the hardware (0x0210)
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 	       struct ice_sq_cd *cd)
 {
@@ -331,7 +331,7 @@ ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  *
  * Free VSI context info from hardware (0x0213)
  */
-static enum ice_status
+enum ice_status
 ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		bool keep_vsi_alloc, struct ice_sq_cd *cd)
 {
@@ -366,7 +366,7 @@ ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  *
  * Update VSI context in the hardware (0x0211)
  */
-static enum ice_status
+enum ice_status
 ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		  struct ice_sq_cd *cd)
 {
drivers/net/ice/base/ice_switch.h +9 -0
index 90dfdabcb..b28e55a4f 100644
@@ -271,6 +271,15 @@ enum ice_promisc_flags {
 
 /* VSI related commands */
 enum ice_status
+ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+	       struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		bool keep_vsi_alloc, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		  struct ice_sq_cd *cd);
+enum ice_status
 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
 	    struct ice_sq_cd *cd);
 enum ice_status
Signature · 1 line
2.13.6
#8 lore raw

Re: [PATCH 07/37] net/ice/base: declare functions as external

Quoted 8 lines · Qi Zhang

Remove static of below functions and declare them as external APIs.

ice_aq_add_vsi
ice_aq_free_vsi
ice_aq_update_vsi
ice_aq_add_lan_txq
ice_init_pkg

Hi Qi,

This is generic comment for the patchset but it is easy to demonstrate in this patch,

Patch title and comment describes what is done in the code, which is exactly same with what can be seen from the code, so doesn't add more value.

What can't be seen from the below code is "why you need this change?" and "what is the impact of the change?".

Can you please update the patch title to describe what is achieved by the patch but not implementation details.
Also in commit log describe "why it is needed" and "what will be the impact, or impact of not having this change", and of course if the implementation is complex describe the implementation too.

And specific to this patch, this is base code update, most probably it is setting ground to enable some features in driver, wouldn't it be better to do these changes when the relevant driver change done? It sets the context for the update and it helps to review the patch.
Right now it just exposes some APIs without really knowing who will use them, or will anybody use them at all.

Quoted 118 lines
---
 drivers/net/ice/base/ice_common.c    | 2 +-
 drivers/net/ice/base/ice_common.h    | 4 ++++
 drivers/net/ice/base/ice_flex_pipe.c | 2 +-
 drivers/net/ice/base/ice_flex_pipe.h | 2 ++
 drivers/net/ice/base/ice_switch.c    | 6 +++---
 drivers/net/ice/base/ice_switch.h    | 9 +++++++++
 6 files changed, 20 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_common.c +1 -1
index 86d3be17a..015db11e0 100644
@@ -2935,7 +2935,7 @@ ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
  * Association of Tx queue to Doorbell queue is not part of Add LAN Tx queue
  * flow.
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_lan_txq(struct ice_hw *hw, u8 num_qgrps,
 		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
 		   struct ice_sq_cd *cd)
drivers/net/ice/base/ice_common.h +4 -0
index 0b387cdbe..63f4a5ebe 100644
@@ -94,6 +94,10 @@ ice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
 enum ice_status
 ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
 		   struct ice_aqc_get_set_rss_keys *keys);
+enum ice_status
+ice_aq_add_lan_txq(struct ice_hw *hw, u8 count,
+		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
+		   struct ice_sq_cd *cd);
 
 bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq);
 enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);
drivers/net/ice/base/ice_flex_pipe.c +1 -1
index 2d23c36eb..ff615f94f 100644
@@ -1314,7 +1314,7 @@ static void ice_init_pkg_regs(struct ice_hw *hw)
  * ice_copy_and_init_pkg() instead of directly calling ice_init_pkg() in this
  * case.
  */
-static enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
+enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
 {
 	struct ice_pkg_hdr *pkg;
 	enum ice_status status;
drivers/net/ice/base/ice_flex_pipe.h +2 -0
index 23fffed75..00c2b6682 100644
@@ -88,6 +88,8 @@ ice_set_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 cntxt);
 struct ice_prof_map *
 ice_get_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 *cntxt);
 enum ice_status
+ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len);
+enum ice_status
 ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
 enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
 void ice_free_seg(struct ice_hw *hw);
drivers/net/ice/base/ice_switch.c +3 -3
index 512e64b91..e6fc9fcee 100644
@@ -288,7 +288,7 @@ enum ice_status ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id)
  *
  * Add a VSI context to the hardware (0x0210)
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 	       struct ice_sq_cd *cd)
 {
@@ -331,7 +331,7 @@ ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  *
  * Free VSI context info from hardware (0x0213)
  */
-static enum ice_status
+enum ice_status
 ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		bool keep_vsi_alloc, struct ice_sq_cd *cd)
 {
@@ -366,7 +366,7 @@ ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  *
  * Update VSI context in the hardware (0x0211)
  */
-static enum ice_status
+enum ice_status
 ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		  struct ice_sq_cd *cd)
 {
drivers/net/ice/base/ice_switch.h +9 -0
index 90dfdabcb..b28e55a4f 100644
@@ -271,6 +271,15 @@ enum ice_promisc_flags {
 
 /* VSI related commands */
 enum ice_status
+ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+	       struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		bool keep_vsi_alloc, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		  struct ice_sq_cd *cd);
+enum ice_status
 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
 	    struct ice_sq_cd *cd);
 enum ice_status
#9 lore raw

Re: [PATCH 07/37] net/ice/base: declare functions as external

Hi Ferruh:

Quoted 17 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 1, 2019 6:31 PM
To: Zhang, Qi Z <[email protected]>; Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>
Cc: Stillwell Jr, Paul M <[email protected]>; [email protected]
Subject: Re: [PATCH 07/37] net/ice/base: declare functions as external

Quoted 7 lines · Qi Zhang

Remove static of below functions and declare them as external APIs.

ice_aq_add_vsi
ice_aq_free_vsi
ice_aq_update_vsi
ice_aq_add_lan_txq
ice_init_pkg

Quoted 4 lines

Hi Qi,

This is generic comment for the patchset but it is easy to demonstrate in this patch,

OK, I will give generic reply :)

Quoted 6 lines

Patch title and comment describes what is done in the code, which is exactly same with what can be seen from the code, so doesn't add more value.

What can't be seen from the below code is "why you need this change?" and "what is the impact of the change?".

Yes, the patch set include a lot changes that impact nothing from user's view.
For examples it adds API not be used in this release but will be used in future.
The reason we do this early is we want to sync with the latest share code that kernel team delivered to DPDK.

And I think this gives below benefits:
1. Generally, stripped the code only we needed from a kernel delivery will take developer more effort compare to just simply sync to a new delivery. (if we take 5000+ ice_flex_pipe.c for example)
2. Exposed some unused share code API early help developers out of Intel to contribute some new features that rely on those APIs and avoid license issue ( they can reference kernel's share code but can't submit the patch with that part of share code)
3. it help us to deliver succinct RFC patch base on an official release for customer for some new feature evaluation.
3. Same benefit for internal develop for some features for new release, it's easy for team to start a code base that include all the share code we needed.

BTW, as I know this is the same way we do on other Intel drivers ( i40e and ixgbe).

Quoted 7 lines

Can you please update the patch title to describe what is achieved by the patch but not implementation details.
Also in commit log describe "why it is needed" and "what will be the impact, or impact of not having this change", and of course if the implementation is complex describe the implementation too.

Yes, I think it's better to add more explanation base on my previous comment.

Quoted 7 lines

And specific to this patch, this is base code update, most probably it is setting ground to enable some features in driver, wouldn't it be better to do these changes when the relevant driver change done? It sets the context for the update and it helps to review the patch.
Right now it just exposes some APIs without really knowing who will use them, or will anybody use them at all.

As I explained above.

Thanks
Qi

Quoted 126 lines

drivers/net/ice/base/ice_common.c ice_aq_set_rss_key(struct ice_hw *hw, u16

Quoted 19 lines
---
 drivers/net/ice/base/ice_common.c    | 2 +-
 drivers/net/ice/base/ice_common.h    | 4 ++++
 drivers/net/ice/base/ice_flex_pipe.c | 2 +-
drivers/net/ice/base/ice_flex_pipe.h | 2 ++
 drivers/net/ice/base/ice_switch.c    | 6 +++---
 drivers/net/ice/base/ice_switch.h    | 9 +++++++++
 6 files changed, 20 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_common.c +0 -0
index 86d3be17a..015db11e0 100644
@@ -2935,7 +2935,7 @@ ice_aq_set_rss_key(struct ice_hw *hw, u16

vsi_handle,

drivers/net/ice/base/ice_switch.c enum ice_status ice_free_sw(struct ice_hw *hw, u16

Quoted 58 lines
drivers/net/ice/base/ice_common.c +1 -1
  * Association of Tx queue to Doorbell queue is not part of Add LAN Tx queue
  * flow.
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_lan_txq(struct ice_hw *hw, u8 num_qgrps,
 		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
 		   struct ice_sq_cd *cd)
drivers/net/ice/base/ice_common.h +4 -0
index 0b387cdbe..63f4a5ebe 100644
@@ -94,6 +94,10 @@ ice_aq_get_rss_key(struct ice_hw *hw, u16
 vsi_handle,  enum ice_status  ice_aq_set_rss_key(struct ice_hw *hw,
 u16 vsi_handle,
 		   struct ice_aqc_get_set_rss_keys *keys);
+enum ice_status
+ice_aq_add_lan_txq(struct ice_hw *hw, u8 count,
+		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
+		   struct ice_sq_cd *cd);
 
 bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info
 *cq);  enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool

unloading); diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index 2d23c36eb..ff615f94f 100644

drivers/net/ice/base/ice_flex_pipe.c +1 -1
@@ -1314,7 +1314,7 @@ static void ice_init_pkg_regs(struct ice_hw *hw)
  * ice_copy_and_init_pkg() instead of directly calling ice_init_pkg() in this
  * case.
  */
-static enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32
 len)
+enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
 {
 	struct ice_pkg_hdr *pkg;
drivers/net/ice/base/ice_flex_pipe.c +0 -0
 	enum ice_status status;
drivers/net/ice/base/ice_flex_pipe.h +0 -0
index 23fffed75..00c2b6682 100644
@@ -88,6 +88,8 @@ ice_set_prof_context(struct ice_hw *hw, enum

ice_block blk, u64 id, u64 cntxt); struct ice_prof_map * ice_get_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 *cntxt); enum ice_status
+ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len); enum ice_status
ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
enum ice_status ice_init_hw_tbls(struct ice_hw *hw); void ice_free_seg(struct ice_hw *hw); diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index 512e64b91..e6fc9fcee 100644

drivers/net/ice/base/ice_switch.c +0 -0
@@ -288,7 +288,7 @@ enum ice_status ice_free_sw(struct ice_hw *hw, u16

sw_id, u16 counter_id)

drivers/net/ice/base/ice_switch.c ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx

Quoted 9 lines
drivers/net/ice/base/ice_switch.c +1 -1
  *
  * Add a VSI context to the hardware (0x0210)
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 	       struct ice_sq_cd *cd)
 {
@@ -331,7 +331,7 @@ ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx

*vsi_ctx,

Quoted 37 lines
drivers/net/ice/base/ice_switch.c +1 -1
  *
  * Free VSI context info from hardware (0x0213)
  */
-static enum ice_status
+enum ice_status
 ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		bool keep_vsi_alloc, struct ice_sq_cd *cd)  { @@ -366,7 +366,7 @@
 ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,

*
* Update VSI context in the hardware (0x0211)
*/

drivers/net/ice/base/ice_switch.c +1 -1
-static enum ice_status
+enum ice_status
 ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		  struct ice_sq_cd *cd)
 {
drivers/net/ice/base/ice_switch.h +8 -0
index 90dfdabcb..b28e55a4f 100644
@@ -271,6 +271,15 @@ enum ice_promisc_flags {
 
 /* VSI related commands */
 enum ice_status
+ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+	       struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		bool keep_vsi_alloc, struct ice_sq_cd *cd); enum ice_status
+ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		  struct ice_sq_cd *cd);
+enum ice_status
 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
 	    struct ice_sq_cd *cd);
 enum ice_status
author
#10 lore raw

PATCH 8/37 net/ice/base: add more APIs in switch module

In reply to Qi Zhang

Add below APIs in switch module

1. ice_aq_get_vsi_params - get VSI context info
2. ice_aq_add_update_mir_rule - add/update mirror rule
3. ice_aq_delete_mir_rule - delete mirror rule
4. ice_aq_set_storm_ctrl - set storm control configuration
5. ice_aq_get_storm_ctrl - get storm control configuration

---
 drivers/net/ice/base/ice_adminq_cmd.h | 136 ++++++++++++++++++++
 drivers/net/ice/base/ice_switch.c     | 228 ++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h     |  29 +++++
 3 files changed, 393 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +136 -0
index 056a9fbef..724657af6 100644
@@ -177,6 +177,13 @@ struct ice_aqc_clear_pxe {
 };
 
 
+/* Configure No-Drop Policy Command (direct 0x0112) */
+struct ice_aqc_config_no_drop_policy {
+	u8 opts;
+#define ICE_AQC_FORCE_NO_DROP			BIT(0)
+	u8 rsvd[15];
+};
+
 /* Get switch configuration (0x0200) */
 struct ice_aqc_get_sw_cfg {
 	/* Reserved for command and copy of request flags for response */
@@ -350,6 +357,19 @@ struct ice_aqc_add_update_free_vsi_resp {
 };
 
 
+struct ice_aqc_get_vsi_resp {
+	__le16 vsi_num;
+	u8 vf_id;
+	/* The vsi_flags field uses the ICE_AQ_VSI_TYPE_* defines for values.
+	 * These are found above in struct ice_aqc_add_get_update_free_vsi.
+	 */
+	u8 vsi_flags;
+	__le16 vsi_used;
+	__le16 vsi_free;
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
 
 struct ice_aqc_vsi_props {
 	__le16 valid_sections;
@@ -506,6 +526,110 @@ struct ice_aqc_vsi_props {
 };
 
 
+/* Add/update mirror rule - direct (0x0260) */
+#define ICE_AQC_RULE_ID_VALID_S		7
+#define ICE_AQC_RULE_ID_VALID_M		(0x1 << ICE_AQC_RULE_ID_VALID_S)
+#define ICE_AQC_RULE_ID_S		0
+#define ICE_AQC_RULE_ID_M		(0x3F << ICE_AQC_RULE_ID_S)
+
+/* Following defines to be used while processing caller specified mirror list
+ * of VSI indexes.
+ */
+/* Action: Byte.bit (1.7)
+ *	0 = Remove VSI from mirror rule
+ *	1 = Add VSI to mirror rule
+ */
+#define ICE_AQC_RULE_ACT_S	15
+#define ICE_AQC_RULE_ACT_M	(0x1 << ICE_AQC_RULE_ACT_S)
+/* Action: 1.2:0.0 = Mirrored VSI */
+#define ICE_AQC_RULE_MIRRORED_VSI_S	0
+#define ICE_AQC_RULE_MIRRORED_VSI_M	(0x7FF << ICE_AQC_RULE_MIRRORED_VSI_S)
+
+/* This is to be used by add/update mirror rule Admin Queue command.
+ * In case of add mirror rule - if rule ID is specified as
+ * INVAL_MIRROR_RULE_ID, new rule ID is allocated from shared pool.
+ * If specified rule_id is valid, then it is used. If specified rule_id
+ * is in use then new mirroring rule is added.
+ */
+#define ICE_INVAL_MIRROR_RULE_ID	0xFFFF
+
+struct ice_aqc_add_update_mir_rule {
+	__le16 rule_id;
+
+	__le16 rule_type;
+#define ICE_AQC_RULE_TYPE_S		0
+#define ICE_AQC_RULE_TYPE_M		(0x7 << ICE_AQC_RULE_TYPE_S)
+	/* VPORT ingress/egress */
+#define ICE_AQC_RULE_TYPE_VPORT_INGRESS	0x1
+#define ICE_AQC_RULE_TYPE_VPORT_EGRESS	0x2
+	/* Physical port ingress mirroring.
+	 * All traffic received by this port
+	 */
+#define ICE_AQC_RULE_TYPE_PPORT_INGRESS	0x6
+	/* Physical port egress mirroring. All traffic sent by this port */
+#define ICE_AQC_RULE_TYPE_PPORT_EGRESS	0x7
+
+	/* Number of mirrored entries.
+	 * The values are in the command buffer
+	 */
+	__le16 num_entries;
+
+	/* Destination VSI */
+	__le16 dest;
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
+/* Delete mirror rule - direct(0x0261) */
+struct ice_aqc_delete_mir_rule {
+	__le16 rule_id;
+	__le16 rsvd;
+
+	/* Byte.bit: 20.0 = Keep allocation. If set VSI stays part of
+	 * the PF allocated resources, otherwise it is returned to the
+	 * shared pool
+	 */
+#define ICE_AQC_FLAG_KEEP_ALLOCD_S	0
+#define ICE_AQC_FLAG_KEEP_ALLOCD_M	(0x1 << ICE_AQC_FLAG_KEEP_ALLOCD_S)
+	__le16 flags;
+
+	u8 reserved[10];
+};
+
+/* Set/Get storm config - (direct 0x0280, 0x0281) */
+/* This structure holds get storm configuration response and same structure
+ * is used to perform set_storm_cfg
+ */
+struct ice_aqc_storm_cfg {
+	__le32 bcast_thresh_size;
+	__le32 mcast_thresh_size;
+	/* Bit 18:0 - Traffic upper threshold size
+	 * Bit 31:19 - Reserved
+	 */
+#define ICE_AQ_THRESHOLD_S	0
+#define ICE_AQ_THRESHOLD_M	(0x7FFFF << ICE_AQ_THRESHOLD_S)
+
+	__le32 storm_ctrl_ctrl;
+	/* Bit 0: MDIPW - Drop Multicast packets in previous window
+	 * Bit 1: MDICW - Drop multicast packets in current window
+	 * Bit 2: BDIPW - Drop broadcast packets in previous window
+	 * Bit 3: BDICW - Drop broadcast packets in current window
+	 */
+#define ICE_AQ_STORM_CTRL_MDIPW_DROP_MULTICAST	BIT(0)
+#define ICE_AQ_STORM_CTRL_MDICW_DROP_MULTICAST	BIT(1)
+#define ICE_AQ_STORM_CTRL_BDIPW_DROP_MULTICAST	BIT(2)
+#define ICE_AQ_STORM_CTRL_BDICW_DROP_MULTICAST	BIT(3)
+	/* Bit 7:5 : Reserved */
+	/* Bit 27:8 : Interval - BSC/MSC Time-interval specification: The
+	 * interval size for applying ingress broadcast or multicast storm
+	 * control.
+	 */
+#define ICE_AQ_STORM_BSC_MSC_TIME_INTERVAL_S	8
+#define ICE_AQ_STORM_BSC_MSC_TIME_INTERVAL_M	\
+			(0xFFFFF << ICE_AQ_STORM_BSC_MSC_TIME_INTERVAL_S)
+	__le32 reserved;
+};
+
 
 #define ICE_MAX_NUM_RECIPES 64
 
@@ -1771,6 +1895,9 @@ struct ice_aq_desc {
 		struct ice_aqc_manage_mac_read mac_read;
 		struct ice_aqc_manage_mac_write mac_write;
 		struct ice_aqc_clear_pxe clear_pxe;
+		struct ice_aqc_config_no_drop_policy no_drop;
+		struct ice_aqc_add_update_mir_rule add_update_rule;
+		struct ice_aqc_delete_mir_rule del_rule;
 		struct ice_aqc_list_caps get_cap;
 		struct ice_aqc_get_phy_caps get_phy;
 		struct ice_aqc_set_phy_cfg set_phy;
@@ -1778,6 +1905,7 @@ struct ice_aq_desc {
 		struct ice_aqc_set_port_id_led set_port_id_led;
 		struct ice_aqc_get_sw_cfg get_sw_conf;
 		struct ice_aqc_sw_rules sw_rules;
+		struct ice_aqc_storm_cfg storm_conf;
 		struct ice_aqc_get_topo get_topo;
 		struct ice_aqc_sched_elem_cmd sched_elem_cmd;
 		struct ice_aqc_query_txsched_res query_sched_res;
@@ -1795,6 +1923,7 @@ struct ice_aq_desc {
 		struct ice_aqc_txqs_cleanup txqs_cleanup;
 		struct ice_aqc_add_get_update_free_vsi vsi_cmd;
 		struct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;
+		struct ice_aqc_get_vsi_resp get_vsi_resp;
 		struct ice_aqc_download_pkg download_pkg;
 		struct ice_aqc_get_pkg_info_list get_pkg_info_list;
 		struct ice_aqc_fw_logging fw_logging;
@@ -1912,6 +2041,13 @@ enum ice_adminq_opc {
 	ice_aqc_opc_get_vsi_params			= 0x0212,
 	ice_aqc_opc_free_vsi				= 0x0213,
 
+	/* Mirroring rules - add/update, delete */
+	ice_aqc_opc_add_update_mir_rule			= 0x0260,
+	ice_aqc_opc_del_mir_rule			= 0x0261,
+
+	/* storm configuration */
+	ice_aqc_opc_set_storm_cfg			= 0x0280,
+	ice_aqc_opc_get_storm_cfg			= 0x0281,
 
 
 	/* switch rules population commands */
drivers/net/ice/base/ice_switch.c +228 -0

241 lines not on this page · raw message

drivers/net/ice/base/ice_switch.h +29 -0
index b28e55a4f..ebcfaa120 100644
@@ -29,6 +29,19 @@ struct ice_vsi_ctx {
 	struct LIST_HEAD_TYPE rss_list_head;
 };
 
+/* This is to be used by add/update mirror rule Admin Queue command */
+struct ice_mir_rule_buf {
+	u16 vsi_idx; /* VSI index */
+
+	/* For each VSI, user can specify whether corresponding VSI
+	 * should be added/removed to/from mirror rule
+	 *
+	 * add mirror rule: this should always be TRUE.
+	 * update mirror rule:  add(true) or remove(false) VSI to/from
+	 * mirror rule
+	 */
+	u8 add;
+};
 
 /* Switch recipe ID enum values are specific to hardware */
 enum ice_sw_lkup_type {
@@ -290,6 +303,22 @@ ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
 	       struct ice_sq_cd *cd);
 struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
 void ice_clear_all_vsi_ctx(struct ice_hw *hw);
+enum ice_status
+ice_aq_get_vsi_params(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		      struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_add_update_mir_rule(struct ice_hw *hw, u16 rule_type, u16 dest_vsi,
+			   u16 count, struct ice_mir_rule_buf *mr_buf,
+			   struct ice_sq_cd *cd, u16 *rule_id);
+enum ice_status
+ice_aq_delete_mir_rule(struct ice_hw *hw, u16 rule_id, bool keep_allocd,
+		       struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_get_storm_ctrl(struct ice_hw *hw, u32 *bcast_thresh, u32 *mcast_thresh,
+		      u32 *ctl_bitmask);
+enum ice_status
+ice_aq_set_storm_ctrl(struct ice_hw *hw, u32 bcast_thresh, u32 mcast_thresh,
+		      u32 ctl_bitmask);
 /* Switch config */
 enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
 
Signature · 1 line
2.13.6
author
#11 lore raw

PATCH 9/37 net/ice/base: add VSI queue context framework

In reply to Qi Zhang

Added code to allocate VSI queue contexts to save the queue specific information like bandwidth etc.

---
 drivers/net/ice/base/ice_sched.c  | 52 +++++++++++++++++++++++++++++++++++----
 drivers/net/ice/base/ice_switch.c | 26 ++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  8 ++++++
 3 files changed, 81 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_sched.c +47 -5
index 237bf7350..ab6097237 100644
@@ -576,6 +576,48 @@ ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids,
 }
 
 /**
+ * ice_alloc_lan_q_ctx - allocate LAN queue contexts for the given VSI and TC
+ * @hw: pointer to the HW struct
+ * @vsi_handle: VSI handle
+ * @tc: TC number
+ * @new_numqs: number of queues
+ */
+static enum ice_status
+ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs)
+{
+	struct ice_vsi_ctx *vsi_ctx;
+	struct ice_q_ctx *q_ctx;
+
+	vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
+	if (!vsi_ctx)
+		return ICE_ERR_PARAM;
+	/* allocate LAN queue contexts */
+	if (!vsi_ctx->lan_q_ctx[tc]) {
+		vsi_ctx->lan_q_ctx[tc] = (struct ice_q_ctx *)
+			ice_calloc(hw, new_numqs, sizeof(*q_ctx));
+		if (!vsi_ctx->lan_q_ctx[tc])
+			return ICE_ERR_NO_MEMORY;
+		vsi_ctx->num_lan_q_entries[tc] = new_numqs;
+		return ICE_SUCCESS;
+	}
+	/* num queues are increased, update the queue contexts */
+	if (new_numqs > vsi_ctx->num_lan_q_entries[tc]) {
+		u16 prev_num = vsi_ctx->num_lan_q_entries[tc];
+
+		q_ctx = (struct ice_q_ctx *)
+			ice_calloc(hw, new_numqs, sizeof(*q_ctx));
+		if (!q_ctx)
+			return ICE_ERR_NO_MEMORY;
+		ice_memcpy(q_ctx, vsi_ctx->lan_q_ctx[tc],
+			   prev_num * sizeof(*q_ctx), ICE_DMA_TO_NONDMA);
+		ice_free(hw, vsi_ctx->lan_q_ctx[tc]);
+		vsi_ctx->lan_q_ctx[tc] = q_ctx;
+		vsi_ctx->num_lan_q_entries[tc] = new_numqs;
+	}
+	return ICE_SUCCESS;
+}
+
+/**
  * ice_aq_rl_profile - performs a rate limiting task
  * @hw: pointer to the HW struct
  * @opcode:opcode for add, query, or remove profile(s)
@@ -1717,14 +1759,14 @@ ice_sched_update_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,
 	if (!vsi_ctx)
 		return ICE_ERR_PARAM;
 
-	if (owner == ICE_SCHED_NODE_OWNER_LAN)
-		prev_numqs = vsi_ctx->sched.max_lanq[tc];
-	else
-		return ICE_ERR_PARAM;
-
+	prev_numqs = vsi_ctx->sched.max_lanq[tc];
 	/* num queues are not changed or less than the previous number */
 	if (new_numqs <= prev_numqs)
 		return status;
+	status = ice_alloc_lan_q_ctx(hw, vsi_handle, tc, new_numqs);
+	if (status)
+		return status;
+
 	if (new_numqs)
 		ice_sched_calc_vsi_child_nodes(hw, new_numqs, new_num_nodes);
 	/* Keep the max number of queue configuration all the time. Update the
drivers/net/ice/base/ice_switch.c +26 -0
index 34637c1be..4b53636b4 100644
@@ -3,6 +3,8 @@
  */
 
 #include "ice_switch.h"
+#include "ice_flex_type.h"
+#include "ice_flow.h"
 
 
 #define ICE_ETH_DA_OFFSET		0
@@ -447,6 +449,27 @@ ice_save_vsi_ctx(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi)
 }
 
 /**
+ * ice_clear_vsi_q_ctx - clear VSI queue contexts for all TCs
+ * @hw: pointer to the HW struct
+ * @vsi_handle: VSI handle
+ */
+static void ice_clear_vsi_q_ctx(struct ice_hw *hw, u16 vsi_handle)
+{
+	struct ice_vsi_ctx *vsi;
+	u8 i;
+
+	vsi = ice_get_vsi_ctx(hw, vsi_handle);
+	if (!vsi)
+		return;
+	ice_for_each_traffic_class(i) {
+		if (vsi->lan_q_ctx[i]) {
+			ice_free(hw, vsi->lan_q_ctx[i]);
+			vsi->lan_q_ctx[i] = NULL;
+		}
+	}
+}
+
+/**
  * ice_clear_vsi_ctx - clear the VSI context entry
  * @hw: pointer to the HW struct
  * @vsi_handle: VSI handle
@@ -459,6 +482,9 @@ static void ice_clear_vsi_ctx(struct ice_hw *hw, u16 vsi_handle)
 
 	vsi = ice_get_vsi_ctx(hw, vsi_handle);
 	if (vsi) {
+		if (!LIST_EMPTY(&vsi->rss_list_head))
+			ice_rem_all_rss_vsi_ctx(hw, vsi_handle);
+		ice_clear_vsi_q_ctx(hw, vsi_handle);
 		ice_destroy_lock(&vsi->rss_locks);
 		ice_free(hw, vsi);
 		hw->vsi_ctx[vsi_handle] = NULL;
drivers/net/ice/base/ice_switch.h +8 -0
index ebcfaa120..c6d31475c 100644
@@ -15,6 +15,12 @@
 
 
 #define ICE_VSI_INVAL_ID 0xFFFF
+#define ICE_INVAL_Q_HANDLE 0xFFFF
+
+/* VSI queue context structure */
+struct ice_q_ctx {
+	u16  q_handle;
+};
 
 /* VSI context structure for add/get/update/free operations */
 struct ice_vsi_ctx {
@@ -25,6 +31,8 @@ struct ice_vsi_ctx {
 	struct ice_aqc_vsi_props info;
 	struct ice_sched_vsi_info sched;
 	u8 alloc_from_pool;
+	u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
+	struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
 	struct ice_lock rss_locks;	/* protect rss config in VSI ctx */
 	struct LIST_HEAD_TYPE rss_list_head;
 };
Signature · 1 line
2.13.6
author
#12 lore raw

PATCH 10/37 net/ice/base: add APIs to add remove ethertype filter

In reply to Qi Zhang

Add API ice_remove_eth_mac and ice_add_eth_mac to support adding / removing ethertype (or MAC) based filter rules.

---
 drivers/net/ice/base/ice_switch.c | 57 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  4 +++
 2 files changed, 61 insertions(+)
drivers/net/ice/base/ice_switch.c +57 -0
index 4b53636b4..4af6a323c 100644
@@ -2415,6 +2415,63 @@ ice_add_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *mv_list)
 }
 #endif
 
+/**
+ * ice_add_eth_mac - Add ethertype and MAC based filter rule
+ * @hw: pointer to the hardware structure
+ * @em_list: list of ether type MAC filter, MAC is optional
+ */
+enum ice_status
+ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list)
+{
+	struct ice_fltr_list_entry *em_list_itr;
+
+	LIST_FOR_EACH_ENTRY(em_list_itr, em_list, ice_fltr_list_entry,
+			    list_entry) {
+		enum ice_sw_lkup_type l_type =
+			em_list_itr->fltr_info.lkup_type;
+
+		if (l_type != ICE_SW_LKUP_ETHERTYPE_MAC &&
+		    l_type != ICE_SW_LKUP_ETHERTYPE)
+			return ICE_ERR_PARAM;
+
+		em_list_itr->fltr_info.flag = ICE_FLTR_TX;
+		em_list_itr->status = ice_add_rule_internal(hw, l_type,
+							    em_list_itr);
+		if (em_list_itr->status)
+			return em_list_itr->status;
+	}
+	return ICE_SUCCESS;
+}
+
+/**
+ * ice_remove_eth_mac - Remove an ethertype (or MAC) based filter rule
+ * @hw: pointer to the hardware structure
+ * @em_list: list of ethertype or ethertype MAC entries
+ */
+enum ice_status
+ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list)
+{
+	struct ice_fltr_list_entry *em_list_itr, *tmp;
+
+	if (!em_list || !hw)
+		return ICE_ERR_PARAM;
+
+	LIST_FOR_EACH_ENTRY_SAFE(em_list_itr, tmp, em_list, ice_fltr_list_entry,
+				 list_entry) {
+		enum ice_sw_lkup_type l_type =
+			em_list_itr->fltr_info.lkup_type;
+
+		if (l_type != ICE_SW_LKUP_ETHERTYPE_MAC &&
+		    l_type != ICE_SW_LKUP_ETHERTYPE)
+			return ICE_ERR_PARAM;
+
+		em_list_itr->status = ice_remove_rule_internal(hw, l_type,
+							       em_list_itr);
+		if (em_list_itr->status)
+			return em_list_itr->status;
+	}
+	return ICE_SUCCESS;
+}
 
 
 /**
drivers/net/ice/base/ice_switch.h +4 -0
index c6d31475c..f331621e1 100644
@@ -347,6 +347,10 @@ ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status
+ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
+enum ice_status
+ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
+enum ice_status
 ice_remove_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
 #ifndef NO_MACVLAN_SUPPORT
 enum ice_status
Signature · 1 line
2.13.6
author
#13 lore raw

PATCH 11/37 net/ice/base: add APIs to get allocated resources

In reply to Qi Zhang

1. ice_aq_get_res_alloc - get allocated resources.
2. ice_aq_get_res_descs - get allocated resource descriptors.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 53 +++++++++++++++++++++-
 drivers/net/ice/base/ice_switch.c     | 83 +++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h     | 12 +++++
 3 files changed, 147 insertions(+), 1 deletion(-)
drivers/net/ice/base/ice_adminq_cmd.h +52 -1
index 724657af6..ca3d40c8b 100644
@@ -281,6 +281,34 @@ struct ice_aqc_get_sw_cfg_resp {
 
 #define ICE_AQC_RES_TYPE_FLAG_DEDICATED			0x00
 
+#define ICE_AQC_RES_TYPE_S	0
+#define ICE_AQC_RES_TYPE_M	(0x07F << ICE_AQC_RES_TYPE_S)
+
+/* Get Resource Allocation command (indirect 0x0204) */
+struct ice_aqc_get_res_alloc {
+	__le16 resp_elem_num; /* Used in response, reserved in command */
+	u8 reserved[6];
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
+/* Get Resource Allocation Response Buffer per response */
+struct ice_aqc_get_res_resp_elem {
+	__le16 res_type; /* Types defined above cmd 0x0204 */
+	__le16 total_capacity; /* Resources available to all PF's */
+	__le16 total_function; /* Resources allocated for a PF */
+	__le16 total_shared; /* Resources allocated as shared */
+	__le16 total_free; /* Resources un-allocated/not reserved by any PF */
+};
+
+/* Buffer for Get Resource command */
+struct ice_aqc_get_res_resp {
+	/* Number of resource entries to be calculated using
+	 * datalen/sizeof(struct ice_aqc_cmd_resp)).
+	 * Value of 'datalen' gets updated as part of response.
+	 */
+	struct ice_aqc_get_res_resp_elem elem[1];
+};
 
 
 /* Allocate Resources command (indirect 0x0208)
@@ -314,6 +342,28 @@ struct ice_aqc_alloc_free_res_elem {
 };
 
 
+/* Get Allocated Resource Descriptors Command (indirect 0x020A) */
+struct ice_aqc_get_allocd_res_desc {
+	union {
+		struct {
+			__le16 res; /* Types defined above cmd 0x0204 */
+			__le16 first_desc;
+			__le32 reserved;
+		} cmd;
+		struct {
+			__le16 res;
+			__le16 next_desc;
+			__le16 num_desc;
+			__le16 reserved;
+		} resp;
+	} ops;
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
+struct ice_aqc_get_allocd_res_desc_resp {
+	struct ice_aqc_res_elem elem[1];
+};
 
 
 /* Add VSI (indirect 0x0210)
@@ -1912,7 +1962,6 @@ struct ice_aq_desc {
 		struct ice_aqc_query_node_to_root query_node_to_root;
 		struct ice_aqc_cfg_l2_node_cgd cfg_l2_node_cgd;
 		struct ice_aqc_rl_profile rl_profile;
-
 		struct ice_aqc_nvm nvm;
 		struct ice_aqc_nvm_cfg nvm_cfg;
 		struct ice_aqc_nvm_checksum nvm_checksum;
@@ -1930,6 +1979,8 @@ struct ice_aq_desc {
 		struct ice_aqc_get_clear_fw_log get_clear_fw_log;
 		struct ice_aqc_set_mac_lb set_mac_lb;
 		struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
+		struct ice_aqc_get_res_alloc get_res;
+		struct ice_aqc_get_allocd_res_desc get_res_desc;
 		struct ice_aqc_set_mac_cfg set_mac_cfg;
 		struct ice_aqc_set_event_mask set_event_mask;
 		struct ice_aqc_get_link_status get_link_status;
drivers/net/ice/base/ice_switch.c +83 -0

89 lines not on this page · raw message

drivers/net/ice/base/ice_switch.h +12 -0
index f331621e1..4b77d920f 100644
@@ -13,6 +13,10 @@
 #define ICE_DFLT_VSI_INVAL 0xff
 
 
+/* Worst case buffer length for ice_aqc_opc_get_res_alloc */
+#define ICE_MAX_RES_TYPES 0x80
+#define ICE_AQ_GET_RES_ALLOC_BUF_LEN \
+	(ICE_MAX_RES_TYPES * sizeof(struct ice_aqc_get_res_resp_elem))
 
 #define ICE_VSI_INVAL_ID 0xFFFF
 #define ICE_INVAL_Q_HANDLE 0xFFFF
@@ -343,6 +347,14 @@ ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
 enum ice_status
 ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id);
 enum ice_status
+ice_aq_get_res_alloc(struct ice_hw *hw, u16 *num_entries, void *buf,
+		     u16 buf_size, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_get_res_descs(struct ice_hw *hw, u16 num_entries,
+		     struct ice_aqc_get_allocd_res_desc_resp *buf,
+		     u16 buf_size, u16 res_type, bool res_shared, u16 *desc_id,
+		     struct ice_sq_cd *cd);
+enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
Signature · 1 line
2.13.6
author
#14 lore raw

PATCH 12/37 net/ice/base: add APIs to alloc/free VLAN resource counter

In reply to Qi Zhang

1. ice_alloc_res_cntr - allocate resource counter
2. ice_free_res_cntr - free resource counter
3. ice_alloc_vlan_res_counter - allocate vlan resource counter
4. ice_free_vlan_res_counter - free vlan resource counter

---
 drivers/net/ice/base/ice_switch.c | 97 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  6 +++
 2 files changed, 103 insertions(+)
drivers/net/ice/base/ice_switch.c +97 -0
index c985c1e31..26fc0b46b 100644
@@ -3238,9 +3238,106 @@ void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle)
 	ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_PROMISC_VLAN);
 }
 
+/**
+ * ice_alloc_res_cntr - allocating resource counter
+ * @hw: pointer to the hardware structure
+ * @type: type of resource
+ * @alloc_shared: if set it is shared else dedicated
+ * @num_items: number of entries requested for FD resource type
+ * @counter_id: counter index returned by AQ call
+ */
+enum ice_status
+ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		   u16 *counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *buf;
+	enum ice_status status;
+	u16 buf_len;
+
+	/* Allocate resource */
+	buf_len = sizeof(*buf);
+	buf = (struct ice_aqc_alloc_free_res_elem *)
+		ice_malloc(hw, buf_len);
+	if (!buf)
+		return ICE_ERR_NO_MEMORY;
+
+	buf->num_elems = CPU_TO_LE16(num_items);
+	buf->res_type = CPU_TO_LE16(((type << ICE_AQC_RES_TYPE_S) &
+				      ICE_AQC_RES_TYPE_M) | alloc_shared);
+
+	status = ice_aq_alloc_free_res(hw, 1, buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+	if (status)
+		goto exit;
+
+	*counter_id = LE16_TO_CPU(buf->elem[0].e.sw_resp);
+
+exit:
+	ice_free(hw, buf);
+	return status;
+}
+
+/**
+ * ice_free_res_cntr - free resource counter
+ * @hw: pointer to the hardware structure
+ * @type: type of resource
+ * @alloc_shared: if set it is shared else dedicated
+ * @num_items: number of entries to be freed for FD resource type
+ * @counter_id: counter ID resource which needs to be freed
+ */
+enum ice_status
+ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		  u16 counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *buf;
+	enum ice_status status;
+	u16 buf_len;
 
+	/* Free resource */
+	buf_len = sizeof(*buf);
+	buf = (struct ice_aqc_alloc_free_res_elem *)
+		ice_malloc(hw, buf_len);
+	if (!buf)
+		return ICE_ERR_NO_MEMORY;
 
+	buf->num_elems = CPU_TO_LE16(num_items);
+	buf->res_type = CPU_TO_LE16(((type << ICE_AQC_RES_TYPE_S) &
+				      ICE_AQC_RES_TYPE_M) | alloc_shared);
+	buf->elem[0].e.sw_resp = CPU_TO_LE16(counter_id);
 
+	status = ice_aq_alloc_free_res(hw, 1, buf, buf_len,
+				       ice_aqc_opc_free_res, NULL);
+	if (status)
+		ice_debug(hw, ICE_DBG_SW,
+			  "counter resource could not be freed\n");
+
+	ice_free(hw, buf);
+	return status;
+}
+
+/**
+ * ice_alloc_vlan_res_counter - obtain counter resource for VLAN type
+ * @hw: pointer to the hardware structure
+ * @counter_id: returns counter index
+ */
+enum ice_status ice_alloc_vlan_res_counter(struct ice_hw *hw, u16 *counter_id)
+{
+	return ice_alloc_res_cntr(hw, ICE_AQC_RES_TYPE_VLAN_COUNTER,
+				  ICE_AQC_RES_TYPE_FLAG_DEDICATED, 1,
+				  counter_id);
+}
+
+/**
+ * ice_free_vlan_res_counter - Free counter resource for VLAN type
+ * @hw: pointer to the hardware structure
+ * @counter_id: counter index to be freed
+ */
+enum ice_status ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id)
+{
+	return ice_free_res_cntr(hw, ICE_AQC_RES_TYPE_VLAN_COUNTER,
+				 ICE_AQC_RES_TYPE_FLAG_DEDICATED, 1,
+				 counter_id);
+}
 
 /**
  * ice_replay_vsi_fltr - Replay filters for requested VSI
drivers/net/ice/base/ice_switch.h +6 -0
index 4b77d920f..364083eb4 100644
@@ -338,6 +338,12 @@ enum ice_status
 ice_alloc_vlan_res_counter(struct ice_hw *hw, u16 *counter_id);
 enum ice_status
 ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
+enum ice_status
+ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		   u16 *counter_id);
+enum ice_status
+ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		  u16 counter_id);
 
 /* Switch/bridge related commands */
 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
Signature · 1 line
2.13.6
author
#15 lore raw

PATCH 13/37 net/ice/base: add APIs to get VSI promiscuous mode

In reply to Qi Zhang

1. ice_get_vsi_promisc - get promiscuous mode of give VSI.
2. ice_get_vsi_vlan_promisc - get VLAN promiscuous mode of given VSI.

---
 drivers/net/ice/base/ice_switch.c | 79 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  7 ++++
 2 files changed, 86 insertions(+)
drivers/net/ice/base/ice_switch.c +79 -0
index 26fc0b46b..e4024a0b0 100644
@@ -2894,6 +2894,85 @@ static u8 ice_determine_promisc_mask(struct ice_fltr_info *fi)
 	return promisc_mask;
 }
 
+/**
+ * ice_get_vsi_promisc - get promiscuous mode of given VSI
+ * @hw: pointer to the hardware structure
+ * @vsi_handle: VSI handle to retrieve info from
+ * @promisc_mask: pointer to mask to be filled in
+ * @vid: VLAN ID of promisc VLAN VSI
+ */
+enum ice_status
+ice_get_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+		    u16 *vid)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *itr;
+	struct LIST_HEAD_TYPE *rule_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+
+	if (!ice_is_vsi_valid(hw, vsi_handle))
+		return ICE_ERR_PARAM;
+
+	*vid = 0;
+	*promisc_mask = 0;
+	rule_head = &sw->recp_list[ICE_SW_LKUP_PROMISC].filt_rules;
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_PROMISC].filt_rule_lock;
+
+	ice_acquire_lock(rule_lock);
+	LIST_FOR_EACH_ENTRY(itr, rule_head,
+			    ice_fltr_mgmt_list_entry, list_entry) {
+		/* Continue if this filter doesn't apply to this VSI or the
+		 * VSI ID is not in the VSI map for this filter
+		 */
+		if (!ice_vsi_uses_fltr(itr, vsi_handle))
+			continue;
+
+		*promisc_mask |= ice_determine_promisc_mask(&itr->fltr_info);
+	}
+	ice_release_lock(rule_lock);
+
+	return ICE_SUCCESS;
+}
+
+/**
+ * ice_get_vsi_vlan_promisc - get VLAN promiscuous mode of given VSI
+ * @hw: pointer to the hardware structure
+ * @vsi_handle: VSI handle to retrieve info from
+ * @promisc_mask: pointer to mask to be filled in
+ * @vid: VLAN ID of promisc VLAN VSI
+ */
+enum ice_status
+ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+			 u16 *vid)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *itr;
+	struct LIST_HEAD_TYPE *rule_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+
+	if (!ice_is_vsi_valid(hw, vsi_handle))
+		return ICE_ERR_PARAM;
+
+	*vid = 0;
+	*promisc_mask = 0;
+	rule_head = &sw->recp_list[ICE_SW_LKUP_PROMISC_VLAN].filt_rules;
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_PROMISC_VLAN].filt_rule_lock;
+
+	ice_acquire_lock(rule_lock);
+	LIST_FOR_EACH_ENTRY(itr, rule_head, ice_fltr_mgmt_list_entry,
+			    list_entry) {
+		/* Continue if this filter doesn't apply to this VSI or the
+		 * VSI ID is not in the VSI map for this filter
+		 */
+		if (!ice_vsi_uses_fltr(itr, vsi_handle))
+			continue;
+
+		*promisc_mask |= ice_determine_promisc_mask(&itr->fltr_info);
+	}
+	ice_release_lock(rule_lock);
+
+	return ICE_SUCCESS;
+}
 
 /**
  * ice_remove_promisc - Remove promisc based filter rules
drivers/net/ice/base/ice_switch.h +7 -0
index 364083eb4..0d70b38f4 100644
@@ -394,6 +394,13 @@ enum ice_status
 ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
 			 bool rm_vlan_promisc);
 
+/* Get VSIs Promisc/defport settings */
+enum ice_status
+ice_get_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+		    u16 *vid);
+enum ice_status
+ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+			 u16 *vid);
 
 
 
Signature · 1 line
2.13.6
author
#16 lore raw

PATCH 14/37 net/ice/base: add MAC filter with marker and counter

In reply to Qi Zhang

1. ice_add_mac_with_sw_marker - add filter with software marker.
2. ice_add_mac_with_counter - add filter with counter enabled.

---
 drivers/net/ice/base/ice_switch.c | 328 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   5 +
 2 files changed, 333 insertions(+)
drivers/net/ice/base/ice_switch.c +328 -0
index e4024a0b0..bfcb33ea6 100644
@@ -1338,6 +1338,95 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
 	return status;
 }
 
+/**
+ * ice_add_counter_act - add/update filter rule with counter action
+ * @hw: pointer to the hardware structure
+ * @m_ent: the management entry for which counter needs to be added
+ * @counter_id: VLAN counter ID returned as part of allocate resource
+ * @l_id: large action resource ID
+ */
+static enum ice_status
+ice_add_counter_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
+		    u16 counter_id, u16 l_id)
+{
+	struct ice_aqc_sw_rules_elem *lg_act;
+	struct ice_aqc_sw_rules_elem *rx_tx;
+	enum ice_status status;
+	/* 2 actions will be added while adding a large action counter */
+	const int num_acts = 2;
+	u16 lg_act_size;
+	u16 rules_size;
+	u16 f_rule_id;
+	u32 act;
+	u16 id;
+
+	if (m_ent->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
+		return ICE_ERR_PARAM;
+
+	/* Create two back-to-back switch rules and submit them to the HW using
+	 * one memory buffer:
+	 * 1. Large Action
+	 * 2. Look up Tx Rx
+	 */
+	lg_act_size = (u16)ICE_SW_RULE_LG_ACT_SIZE(num_acts);
+	rules_size = lg_act_size + ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
+	lg_act = (struct ice_aqc_sw_rules_elem *)ice_malloc(hw,
+								 rules_size);
+	if (!lg_act)
+		return ICE_ERR_NO_MEMORY;
+
+	rx_tx = (struct ice_aqc_sw_rules_elem *)
+		((u8 *)lg_act + lg_act_size);
+
+	/* Fill in the first switch rule i.e. large action */
+	lg_act->type = CPU_TO_LE16(ICE_AQC_SW_RULES_T_LG_ACT);
+	lg_act->pdata.lg_act.index = CPU_TO_LE16(l_id);
+	lg_act->pdata.lg_act.size = CPU_TO_LE16(num_acts);
+
+	/* First action VSI forwarding or VSI list forwarding depending on how
+	 * many VSIs
+	 */
+	id = (m_ent->vsi_count > 1) ?  m_ent->fltr_info.fwd_id.vsi_list_id :
+		m_ent->fltr_info.fwd_id.hw_vsi_id;
+
+	act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;
+	act |= (id << ICE_LG_ACT_VSI_LIST_ID_S) &
+		ICE_LG_ACT_VSI_LIST_ID_M;
+	if (m_ent->vsi_count > 1)
+		act |= ICE_LG_ACT_VSI_LIST;
+	lg_act->pdata.lg_act.act[0] = CPU_TO_LE32(act);
+
+	/* Second action counter ID */
+	act = ICE_LG_ACT_STAT_COUNT;
+	act |= (counter_id << ICE_LG_ACT_STAT_COUNT_S) &
+		ICE_LG_ACT_STAT_COUNT_M;
+	lg_act->pdata.lg_act.act[1] = CPU_TO_LE32(act);
+
+	/* call the fill switch rule to fill the lookup Tx Rx structure */
+	ice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx,
+			 ice_aqc_opc_update_sw_rules);
+
+	act = ICE_SINGLE_ACT_PTR;
+	act |= (l_id << ICE_SINGLE_ACT_PTR_VAL_S) & ICE_SINGLE_ACT_PTR_VAL_M;
+	rx_tx->pdata.lkup_tx_rx.act = CPU_TO_LE32(act);
+
+	/* Use the filter rule ID of the previously created rule with single
+	 * act. Once the update happens, hardware will treat this as large
+	 * action
+	 */
+	f_rule_id = m_ent->fltr_info.fltr_rule_id;
+	rx_tx->pdata.lkup_tx_rx.index = CPU_TO_LE16(f_rule_id);
+
+	status = ice_aq_sw_rules(hw, lg_act, rules_size, 2,
+				 ice_aqc_opc_update_sw_rules, NULL);
+	if (!status) {
+		m_ent->lg_act_idx = l_id;
+		m_ent->counter_index = counter_id;
+	}
+
+	ice_free(hw, lg_act);
+	return status;
+}
 
 /**
  * ice_create_vsi_list_map
@@ -3419,6 +3508,245 @@ enum ice_status ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id)
 }
 
 /**
+ * ice_alloc_res_lg_act - add large action resource
+ * @hw: pointer to the hardware structure
+ * @l_id: large action ID to fill it in
+ * @num_acts: number of actions to hold with a large action entry
+ */
+static enum ice_status
+ice_alloc_res_lg_act(struct ice_hw *hw, u16 *l_id, u16 num_acts)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf;
+	enum ice_status status;
+	u16 buf_len;
+
+	if (num_acts > ICE_MAX_LG_ACT || num_acts == 0)
+		return ICE_ERR_PARAM;
+
+	/* Allocate resource for large action */
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	sw_buf->num_elems = CPU_TO_LE16(1);
+
+	/* If num_acts is 1, use ICE_AQC_RES_TYPE_WIDE_TABLE_1.
+	 * If num_acts is 2, use ICE_AQC_RES_TYPE_WIDE_TABLE_3.
+	 * If num_acts is greater than 2, then use
+	 * ICE_AQC_RES_TYPE_WIDE_TABLE_4.
+	 * The num_acts cannot exceed 4. This was ensured at the
+	 * beginning of the function.
+	 */
+	if (num_acts == 1)
+		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_1);
+	else if (num_acts == 2)
+		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_2);
+	else
+		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_4);
+
+	status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+	if (!status)
+		*l_id = LE16_TO_CPU(sw_buf->elem[0].e.sw_resp);
+
+	ice_free(hw, sw_buf);
+	return status;
+}
+
+/**
+ * ice_add_mac_with_sw_marker - add filter with sw marker
+ * @hw: pointer to the hardware structure
+ * @f_info: filter info structure containing the MAC filter information
+ * @sw_marker: sw marker to tag the Rx descriptor with
+ */
+enum ice_status
+ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,
+			   u16 sw_marker)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *m_entry;
+	struct ice_fltr_list_entry fl_info;
+	struct LIST_HEAD_TYPE l_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+	enum ice_status ret;
+	bool entry_exists;
+	u16 lg_act_id;
+
+	if (f_info->fltr_act != ICE_FWD_TO_VSI)
+		return ICE_ERR_PARAM;
+
+	if (f_info->lkup_type != ICE_SW_LKUP_MAC)
+		return ICE_ERR_PARAM;
+
+	if (sw_marker == ICE_INVAL_SW_MARKER_ID)
+		return ICE_ERR_PARAM;
+
+	if (!ice_is_vsi_valid(hw, f_info->vsi_handle))
+		return ICE_ERR_PARAM;
+	f_info->fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, f_info->vsi_handle);
+
+	/* Add filter if it doesn't exist so then the adding of large
+	 * action always results in update
+	 */
+
+	INIT_LIST_HEAD(&l_head);
+	fl_info.fltr_info = *f_info;
+	LIST_ADD(&fl_info.list_entry, &l_head);
+
+	entry_exists = false;
+	ret = ice_add_mac(hw, &l_head);
+	if (ret == ICE_ERR_ALREADY_EXISTS)
+		entry_exists = true;
+	else if (ret)
+		return ret;
+
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
+	ice_acquire_lock(rule_lock);
+	/* Get the book keeping entry for the filter */
+	m_entry = ice_find_rule_entry(hw, ICE_SW_LKUP_MAC, f_info);
+	if (!m_entry)
+		goto exit_error;
+
+	/* If counter action was enabled for this rule then don't enable
+	 * sw marker large action
+	 */
+	if (m_entry->counter_index != ICE_INVAL_COUNTER_ID) {
+		ret = ICE_ERR_PARAM;
+		goto exit_error;
+	}
+
+	/* if same marker was added before */
+	if (m_entry->sw_marker_id == sw_marker) {
+		ret = ICE_ERR_ALREADY_EXISTS;
+		goto exit_error;
+	}
+
+	/* Allocate a hardware table entry to hold large act. Three actions
+	 * for marker based large action
+	 */
+	ret = ice_alloc_res_lg_act(hw, &lg_act_id, 3);
+	if (ret)
+		goto exit_error;
+
+	if (lg_act_id == ICE_INVAL_LG_ACT_INDEX)
+		goto exit_error;
+
+	/* Update the switch rule to add the marker action */
+	ret = ice_add_marker_act(hw, m_entry, sw_marker, lg_act_id);
+	if (!ret) {
+		ice_release_lock(rule_lock);
+		return ret;
+	}
+
+exit_error:
+	ice_release_lock(rule_lock);
+	/* only remove entry if it did not exist previously */
+	if (!entry_exists)
+		ret = ice_remove_mac(hw, &l_head);
+
+	return ret;
+}
+
+/**
+ * ice_add_mac_with_counter - add filter with counter enabled
+ * @hw: pointer to the hardware structure
+ * @f_info: pointer to filter info structure containing the MAC filter
+ *          information
+ */
+enum ice_status
+ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *m_entry;
+	struct ice_fltr_list_entry fl_info;
+	struct LIST_HEAD_TYPE l_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+	enum ice_status ret;
+	bool entry_exist;
+	u16 counter_id;
+	u16 lg_act_id;
+
+	if (f_info->fltr_act != ICE_FWD_TO_VSI)
+		return ICE_ERR_PARAM;
+
+	if (f_info->lkup_type != ICE_SW_LKUP_MAC)
+		return ICE_ERR_PARAM;
+
+	if (!ice_is_vsi_valid(hw, f_info->vsi_handle))
+		return ICE_ERR_PARAM;
+	f_info->fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, f_info->vsi_handle);
+
+	entry_exist = false;
+
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
+
+	/* Add filter if it doesn't exist so then the adding of large
+	 * action always results in update
+	 */
+	INIT_LIST_HEAD(&l_head);
+
+	fl_info.fltr_info = *f_info;
+	LIST_ADD(&fl_info.list_entry, &l_head);
+
+	ret = ice_add_mac(hw, &l_head);
+	if (ret == ICE_ERR_ALREADY_EXISTS)
+		entry_exist = true;
+	else if (ret)
+		return ret;
+
+	ice_acquire_lock(rule_lock);
+	m_entry = ice_find_rule_entry(hw, ICE_SW_LKUP_MAC, f_info);
+	if (!m_entry) {
+		ret = ICE_ERR_BAD_PTR;
+		goto exit_error;
+	}
+
+	/* Don't enable counter for a filter for which sw marker was enabled */
+	if (m_entry->sw_marker_id != ICE_INVAL_SW_MARKER_ID) {
+		ret = ICE_ERR_PARAM;
+		goto exit_error;
+	}
+
+	/* If a counter was already enabled then don't need to add again */
+	if (m_entry->counter_index != ICE_INVAL_COUNTER_ID) {
+		ret = ICE_ERR_ALREADY_EXISTS;
+		goto exit_error;
+	}
+
+	/* Allocate a hardware table entry to VLAN counter */
+	ret = ice_alloc_vlan_res_counter(hw, &counter_id);
+	if (ret)
+		goto exit_error;
+
+	/* Allocate a hardware table entry to hold large act. Two actions for
+	 * counter based large action
+	 */
+	ret = ice_alloc_res_lg_act(hw, &lg_act_id, 2);
+	if (ret)
+		goto exit_error;
+
+	if (lg_act_id == ICE_INVAL_LG_ACT_INDEX)
+		goto exit_error;
+
+	/* Update the switch rule to add the counter action */
+	ret = ice_add_counter_act(hw, m_entry, counter_id, lg_act_id);
+	if (!ret) {
+		ice_release_lock(rule_lock);
+		return ret;
+	}
+
+exit_error:
+	ice_release_lock(rule_lock);
+	/* only remove entry if it did not exist previously */
+	if (!entry_exist)
+		ret = ice_remove_mac(hw, &l_head);
+
+	return ret;
+}
+
+/**
  * ice_replay_vsi_fltr - Replay filters for requested VSI
  * @hw: pointer to the hardware structure
  * @vsi_handle: driver VSI handle
drivers/net/ice/base/ice_switch.h +5 -0
index 0d70b38f4..b396a486c 100644
@@ -377,6 +377,11 @@ enum ice_status
 ice_remove_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
 #endif /* !NO_MACVLAN_SUPPORT */
 
+enum ice_status
+ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,
+			   u16 sw_marker);
+enum ice_status
+ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info);
 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
 
 
Signature · 1 line
2.13.6
author
#17 lore raw

PATCH 15/37 net/ice/base: add two helper functions for flow management

In reply to Qi Zhang

1. ice_rem_all_sw_rules_info - remove all switch rules.
2. ice_reply_all_fltr - replay all filters stored in book keeping list.

---
 drivers/net/ice/base/ice_switch.c | 107 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   2 +
 2 files changed, 109 insertions(+)
drivers/net/ice/base/ice_switch.c +107 -0
index bfcb33ea6..a0c39b5d7 100644
@@ -2667,6 +2667,23 @@ ice_rem_sw_rule_info(struct ice_hw *hw, struct LIST_HEAD_TYPE *rule_head)
 }
 
 
+/**
+ * ice_rem_all_sw_rules_info
+ * @hw: pointer to the hardware structure
+ */
+void ice_rem_all_sw_rules_info(struct ice_hw *hw)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	u8 i;
+
+	for (i = 0; i < ICE_MAX_NUM_RECIPES; i++) {
+		struct LIST_HEAD_TYPE *rule_head;
+
+		rule_head = &sw->recp_list[i].filt_rules;
+		if (!sw->recp_list[i].adv_rule)
+			ice_rem_sw_rule_info(hw, rule_head);
+	}
+}
 
 /**
  * ice_cfg_dflt_vsi - change state of VSI to set/clear default
@@ -3747,6 +3764,96 @@ ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info)
 }
 
 /**
+ * ice_replay_fltr - Replay all the filters stored by a specific list head
+ * @hw: pointer to the hardware structure
+ * @list_head: list for which filters needs to be replayed
+ * @recp_id: Recipe ID for which rules need to be replayed
+ */
+static enum ice_status
+ice_replay_fltr(struct ice_hw *hw, u8 recp_id, struct LIST_HEAD_TYPE *list_head)
+{
+	struct ice_fltr_mgmt_list_entry *itr;
+	struct LIST_HEAD_TYPE l_head;
+	enum ice_status status = ICE_SUCCESS;
+
+	if (LIST_EMPTY(list_head))
+		return status;
+
+	/* Move entries from the given list_head to a temporary l_head so that
+	 * they can be replayed. Otherwise when trying to re-add the same
+	 * filter, the function will return already exists
+	 */
+	LIST_REPLACE_INIT(list_head, &l_head);
+
+	/* Mark the given list_head empty by reinitializing it so filters
+	 * could be added again by *handler
+	 */
+	LIST_FOR_EACH_ENTRY(itr, &l_head, ice_fltr_mgmt_list_entry,
+			    list_entry) {
+		struct ice_fltr_list_entry f_entry;
+
+		f_entry.fltr_info = itr->fltr_info;
+		if (itr->vsi_count < 2 && recp_id != ICE_SW_LKUP_VLAN) {
+			status = ice_add_rule_internal(hw, recp_id, &f_entry);
+			if (status != ICE_SUCCESS)
+				goto end;
+			continue;
+		}
+
+		/* Add a filter per VSI separately */
+		while (1) {
+			u16 vsi_handle;
+
+			vsi_handle =
+				ice_find_first_bit(itr->vsi_list_info->vsi_map,
+						   ICE_MAX_VSI);
+			if (!ice_is_vsi_valid(hw, vsi_handle))
+				break;
+
+			ice_clear_bit(vsi_handle, itr->vsi_list_info->vsi_map);
+			f_entry.fltr_info.vsi_handle = vsi_handle;
+			f_entry.fltr_info.fwd_id.hw_vsi_id =
+				ice_get_hw_vsi_num(hw, vsi_handle);
+			f_entry.fltr_info.fltr_act = ICE_FWD_TO_VSI;
+			if (recp_id == ICE_SW_LKUP_VLAN)
+				status = ice_add_vlan_internal(hw, &f_entry);
+			else
+				status = ice_add_rule_internal(hw, recp_id,
+							       &f_entry);
+			if (status != ICE_SUCCESS)
+				goto end;
+		}
+	}
+end:
+	/* Clear the filter management list */
+	ice_rem_sw_rule_info(hw, &l_head);
+	return status;
+}
+
+/**
+ * ice_replay_all_fltr - replay all filters stored in bookkeeping lists
+ * @hw: pointer to the hardware structure
+ *
+ * NOTE: This function does not clean up partially added filters on error.
+ * It is up to caller of the function to issue a reset or fail early.
+ */
+enum ice_status ice_replay_all_fltr(struct ice_hw *hw)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	enum ice_status status = ICE_SUCCESS;
+	u8 i;
+
+	for (i = 0; i < ICE_MAX_NUM_RECIPES; i++) {
+		struct LIST_HEAD_TYPE *head = &sw->recp_list[i].filt_rules;
+
+		status = ice_replay_fltr(hw, i, head);
+		if (status != ICE_SUCCESS)
+			return status;
+	}
+	return status;
+}
+
+/**
  * ice_replay_vsi_fltr - Replay filters for requested VSI
  * @hw: pointer to the hardware structure
  * @vsi_handle: driver VSI handle
drivers/net/ice/base/ice_switch.h +2 -0
index b396a486c..3cc2c10e8 100644
@@ -362,6 +362,7 @@ ice_aq_get_res_descs(struct ice_hw *hw, u16 num_entries,
 		     struct ice_sq_cd *cd);
 enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
+void ice_rem_all_sw_rules_info(struct ice_hw *hw);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status
@@ -409,6 +410,7 @@ ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
 
 
 
+enum ice_status ice_replay_all_fltr(struct ice_hw *hw);
 
 enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
Signature · 1 line
2.13.6
author
#18 lore raw

PATCH 16/37 net/ice/base: minor fix

In reply to Qi Zhang

1. ICE_SW_LKUP_LAST need to be handled correctly in ice_aq_alloc_free_vsi_list and ice_update_vsi_list_rule
2. ICE_SW_LKUP_ETHERTYPE_MAC need to be handled correctly in ice_update_vsi_lkup_fltr
3. free package segment pointer during ice_deinit_hw

---
 drivers/net/ice/base/ice_common.c | 1 +
 drivers/net/ice/base/ice_switch.c | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ice/base/ice_common.c +1 -0
index 015db11e0..4085ccc12 100644
@@ -938,6 +938,7 @@ void ice_deinit_hw(struct ice_hw *hw)
 
 	ice_sched_cleanup_all(hw);
 	ice_sched_clear_agg(hw);
+	ice_free_seg(hw);
 
 	if (hw->port_info) {
 		ice_free(hw, hw->port_info);
drivers/net/ice/base/ice_switch.c +6 -2
index a0c39b5d7..e47c1d845 100644
@@ -792,7 +792,8 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE ||
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
 	    lkup_type == ICE_SW_LKUP_PROMISC ||
-	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN) {
+	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN ||
+	    lkup_type == ICE_SW_LKUP_LAST) {
 		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_VSI_LIST_REP);
 	} else if (lkup_type == ICE_SW_LKUP_VLAN) {
 		sw_buf->res_type =
@@ -1492,7 +1493,8 @@ ice_update_vsi_list_rule(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi,
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE ||
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
 	    lkup_type == ICE_SW_LKUP_PROMISC ||
-	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN)
+	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN ||
+	    lkup_type == ICE_SW_LKUP_LAST)
 		type = remove ? ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR :
 				ICE_AQC_SW_RULES_T_VSI_LIST_SET;
 	else if (lkup_type == ICE_SW_LKUP_VLAN)
@@ -3388,6 +3390,8 @@ ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,
 		break;
 	case ICE_SW_LKUP_ETHERTYPE:
 	case ICE_SW_LKUP_ETHERTYPE_MAC:
+		ice_remove_eth_mac(hw, &remove_list_head);
+		break;
 	case ICE_SW_LKUP_DFLT:
 		ice_debug(hw, ICE_DBG_SW,
 			  "Remove filters for this lookup type hasn't been implemented yet\n");
Signature · 1 line
2.13.6
author
#19 lore raw

PATCH 17/37 net/ice/base: update macros

In reply to Qi Zhang

Update macros for metadata and package flags.

---
 drivers/net/ice/base/ice_common.c    | 36 ++++++++---------
 drivers/net/ice/base/ice_flow.h      | 17 ++++++--
 drivers/net/ice/base/ice_lan_tx_rx.h | 77 +++++++++++++++++++++++-------------
 3 files changed, 80 insertions(+), 50 deletions(-)
drivers/net/ice/base/ice_common.c +18 -18
index 4085ccc12..e0fe06e9c 100644
@@ -365,22 +365,22 @@ static void ice_init_flex_flags(struct ice_hw *hw, enum ice_rxdid prof_id)
 	 */
 	case ICE_RXDID_FLEX_NIC:
 	case ICE_RXDID_FLEX_NIC_2:
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_PKT_FRG,
-				   ICE_RXFLG_UDP_GRE, ICE_RXFLG_PKT_DSI,
-				   ICE_RXFLG_FIN, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_PKT_FRG,
+				   ICE_FLG_UDP_GRE, ICE_FLG_PKT_DSI,
+				   ICE_FLG_FIN, idx++);
 		/* flex flag 1 is not used for flexi-flag programming, skipping
 		 * these four FLG64 bits.
 		 */
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_SYN, ICE_RXFLG_RST,
-				   ICE_RXFLG_PKT_DSI, ICE_RXFLG_PKT_DSI, idx++);
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_PKT_DSI,
-				   ICE_RXFLG_PKT_DSI, ICE_RXFLG_EVLAN_x8100,
-				   ICE_RXFLG_EVLAN_x9100, idx++);
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_VLAN_x8100,
-				   ICE_RXFLG_TNL_VLAN, ICE_RXFLG_TNL_MAC,
-				   ICE_RXFLG_TNL0, idx++);
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_TNL1, ICE_RXFLG_TNL2,
-				   ICE_RXFLG_PKT_DSI, ICE_RXFLG_PKT_DSI, idx);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_SYN, ICE_FLG_RST,
+				   ICE_FLG_PKT_DSI, ICE_FLG_PKT_DSI, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_PKT_DSI,
+				   ICE_FLG_PKT_DSI, ICE_FLG_EVLAN_x8100,
+				   ICE_FLG_EVLAN_x9100, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_VLAN_x8100,
+				   ICE_FLG_TNL_VLAN, ICE_FLG_TNL_MAC,
+				   ICE_FLG_TNL0, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_TNL1, ICE_FLG_TNL2,
+				   ICE_FLG_PKT_DSI, ICE_FLG_PKT_DSI, idx);
 		break;
 
 	default:
@@ -399,17 +399,17 @@ static void ice_init_flex_flags(struct ice_hw *hw, enum ice_rxdid prof_id)
  */
 static void ice_init_flex_flds(struct ice_hw *hw, enum ice_rxdid prof_id)
 {
-	enum ice_flex_rx_mdid mdid;
+	enum ice_flex_mdid mdid;
 
 	switch (prof_id) {
 	case ICE_RXDID_FLEX_NIC:
 	case ICE_RXDID_FLEX_NIC_2:
-		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_RX_MDID_HASH_LOW, 0);
-		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_RX_MDID_HASH_HIGH, 1);
-		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_RX_MDID_FLOW_ID_LOWER, 2);
+		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_MDID_RX_HASH_LOW, 0);
+		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_MDID_RX_HASH_HIGH, 1);
+		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_MDID_FLOW_ID_LOWER, 2);
 
 		mdid = (prof_id == ICE_RXDID_FLEX_NIC_2) ?
-			ICE_RX_MDID_SRC_VSI : ICE_RX_MDID_FLOW_ID_HIGH;
+			ICE_MDID_SRC_VSI : ICE_MDID_FLOW_ID_HIGH;
 
 		ICE_PROG_FLEX_ENTRY(hw, prof_id, mdid, 3);
 
drivers/net/ice/base/ice_flow.h +13 -4
index 265e1ee3e..3db10cd6f 100644
@@ -278,14 +278,23 @@ enum ice_flow_action_type {
 	ICE_FLOW_ACT_NOP,
 	ICE_FLOW_ACT_ALLOW,
 	ICE_FLOW_ACT_DROP,
-	ICE_FLOW_ACT_COUNT,
+	ICE_FLOW_ACT_CNTR_PKT,
 	ICE_FLOW_ACT_FWD_VSI,
 	ICE_FLOW_ACT_FWD_VSI_LIST,	/* Should be abstracted away */
 	ICE_FLOW_ACT_FWD_QUEUE,		/* Can Queues be abstracted away? */
 	ICE_FLOW_ACT_FWD_QUEUE_GROUP,	/* Can Queues be abstracted away? */
-	ICE_FLOW_ACTION_PUSH,
-	ICE_FLOW_ACTION_POP,
-	ICE_FLOW_ACTION_MODIFY,
+	ICE_FLOW_ACT_PUSH,
+	ICE_FLOW_ACT_POP,
+	ICE_FLOW_ACT_MODIFY,
+	ICE_FLOW_ACT_CNTR_BYTES,
+	ICE_FLOW_ACT_CNTR_PKT_BYTES,
+	ICE_FLOW_ACT_GENERIC_0,
+	ICE_FLOW_ACT_GENERIC_1,
+	ICE_FLOW_ACT_GENERIC_2,
+	ICE_FLOW_ACT_GENERIC_3,
+	ICE_FLOW_ACT_GENERIC_4,
+	ICE_FLOW_ACT_RPT_FLOW_ID,
+	ICE_FLOW_ACT_BUILD_PROF_IDX,
 };
 
 struct ice_flow_action {
drivers/net/ice/base/ice_lan_tx_rx.h +49 -28

88 lines not on this page · raw message

Signature · 1 line
2.13.6
author
#20 lore raw

PATCH 18/37 net/ice/base: code clean

In reply to Qi Zhang

Change below function as static and also relocated code line to align with kernel driver.

ice_aq_move_sched_elems
ice_sched_get_agg_node
ice_sched_set_node_bw_lmt
ice_sched_cfg_node_bw_alloc
ice_sched_add_agg_cfg
ice_sched_rm_agg_cfg
ice_sched_move_vsi_to_agg
ice_sched_del_rl_profile
ice_sched_rm_unused_rl_prof

---
 drivers/net/ice/base/ice_sched.c | 1038 +++++++++++++++++++-------------------
 drivers/net/ice/base/ice_sched.h |   24 -
 2 files changed, 519 insertions(+), 543 deletions(-)
drivers/net/ice/base/ice_sched.c +519 -519
index ab6097237..2dd9f6f6c 100644
@@ -462,7 +462,7 @@ ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req,
  *
  * Move scheduling elements (0x0408)
  */
-enum ice_status
+static enum ice_status
 ice_aq_move_sched_elems(struct ice_hw *hw, u16 grps_req,
 			struct ice_aqc_move_elem *buf, u16 buf_size,
 			u16 *grps_movd, struct ice_sq_cd *cd)
@@ -713,6 +713,41 @@ ice_aq_remove_rl_profile(struct ice_hw *hw, u16 num_profiles,
 }
 
 /**
+ * ice_sched_del_rl_profile - remove RL profile
+ * @hw: pointer to the HW struct
+ * @rl_info: rate limit profile information
+ *
+ * If the profile ID is not referenced anymore, it removes profile ID with
+ * its associated parameters from HW DB,and locally. The caller needs to
+ * hold scheduler lock.
+ */
+static enum ice_status
+ice_sched_del_rl_profile(struct ice_hw *hw,
+			 struct ice_aqc_rl_profile_info *rl_info)
+{
+	struct ice_aqc_rl_profile_generic_elem *buf;
+	u16 num_profiles_removed;
+	enum ice_status status;
+	u16 num_profiles = 1;
+
+	if (rl_info->prof_id_ref != 0)
+		return ICE_ERR_IN_USE;
+
+	/* Safe to remove profile ID */
+	buf = (struct ice_aqc_rl_profile_generic_elem *)
+		&rl_info->profile;
+	status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf),
+					  &num_profiles_removed, NULL);
+	if (status || num_profiles_removed != num_profiles)
+		return ICE_ERR_CFG;
+
+	/* Delete stale entry now */
+	LIST_DEL(&rl_info->list_entry);
+	ice_free(hw, rl_info);
+	return status;
+}
+
+/**
  * ice_sched_clear_rl_prof - clears RL prof entries
  * @pi: port information structure
  *
@@ -1468,7 +1503,7 @@ ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
  * This function retrieves an aggregator node for a given aggregator ID from
  * a given TC branch
  */
-struct ice_sched_node *
+static struct ice_sched_node *
 ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
 		       u32 agg_id)
 {
@@ -2071,6 +2106,220 @@ ice_get_agg_info(struct ice_hw *hw, u32 agg_id)
 }
 
 /**
+ * ice_sched_get_free_vsi_parent - Find a free parent node in aggregator subtree
+ * @hw: pointer to the HW struct
+ * @node: pointer to a child node
+ * @num_nodes: num nodes count array
+ *
+ * This function walks through the aggregator subtree to find a free parent
+ * node
+ */
+static struct ice_sched_node *
+ice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node,
+			      u16 *num_nodes)
+{
+	u8 l = node->tx_sched_layer;
+	u8 vsil, i;
+
+	vsil = ice_sched_get_vsi_layer(hw);
+
+	/* Is it VSI parent layer ? */
+	if (l == vsil - 1)
+		return (node->num_children < hw->max_children[l]) ? node : NULL;
+
+	/* We have intermediate nodes. Let's walk through the subtree. If the
+	 * intermediate node has space to add a new node then clear the count
+	 */
+	if (node->num_children < hw->max_children[l])
+		num_nodes[l] = 0;
+	/* The below recursive call is intentional and wouldn't go more than
+	 * 2 or 3 iterations.
+	 */
+
+	for (i = 0; i < node->num_children; i++) {
+		struct ice_sched_node *parent;
+
+		parent = ice_sched_get_free_vsi_parent(hw, node->children[i],
+						       num_nodes);
+		if (parent)
+			return parent;
+	}
+
+	return NULL;
+}
+
+/**
+ * ice_sched_update_parent - update the new parent in SW DB
+ * @new_parent: pointer to a new parent node
+ * @node: pointer to a child node
+ *
+ * This function removes the child from the old parent and adds it to a new
+ * parent
+ */
+static void
+ice_sched_update_parent(struct ice_sched_node *new_parent,
+			struct ice_sched_node *node)
+{
+	struct ice_sched_node *old_parent;
+	u8 i, j;
+
+	old_parent = node->parent;
+
+	/* update the old parent children */
+	for (i = 0; i < old_parent->num_children; i++)
+		if (old_parent->children[i] == node) {
+			for (j = i + 1; j < old_parent->num_children; j++)
+				old_parent->children[j - 1] =
+					old_parent->children[j];
+			old_parent->num_children--;
+			break;
+		}
+
+	/* now move the node to a new parent */
+	new_parent->children[new_parent->num_children++] = node;
+	node->parent = new_parent;
+	node->info.parent_teid = new_parent->info.node_teid;
+}
+
+/**
+ * ice_sched_move_nodes - move child nodes to a given parent
+ * @pi: port information structure
+ * @parent: pointer to parent node
+ * @num_items: number of child nodes to be moved
+ * @list: pointer to child node teids
+ *
+ * This function move the child nodes to a given parent.
+ */
+static enum ice_status
+ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
+		     u16 num_items, u32 *list)
+{
+	struct ice_aqc_move_elem *buf;
+	struct ice_sched_node *node;
+	enum ice_status status = ICE_SUCCESS;
+	struct ice_hw *hw;
+	u16 grps_movd = 0;
+	u8 i;
+
+	hw = pi->hw;
+
+	if (!parent || !num_items)
+		return ICE_ERR_PARAM;
+
+	/* Does parent have enough space */
+	if (parent->num_children + num_items >=
+	    hw->max_children[parent->tx_sched_layer])
+		return ICE_ERR_AQ_FULL;
+
+	buf = (struct ice_aqc_move_elem *)ice_malloc(hw, sizeof(*buf));
+	if (!buf)
+		return ICE_ERR_NO_MEMORY;
+
+	for (i = 0; i < num_items; i++) {
+		node = ice_sched_find_node_by_teid(pi->root, list[i]);
+		if (!node) {
+			status = ICE_ERR_PARAM;
+			goto move_err_exit;
+		}
+
+		buf->hdr.src_parent_teid = node->info.parent_teid;
+		buf->hdr.dest_parent_teid = parent->info.node_teid;
+		buf->teid[0] = node->info.node_teid;
+		buf->hdr.num_elems = CPU_TO_LE16(1);
+		status = ice_aq_move_sched_elems(hw, 1, buf, sizeof(*buf),
+						 &grps_movd, NULL);
+		if (status && grps_movd != 1) {
+			status = ICE_ERR_CFG;
+			goto move_err_exit;
+		}
+
+		/* update the SW DB */
+		ice_sched_update_parent(parent, node);
+	}
+
+move_err_exit:
+	ice_free(hw, buf);
+	return status;
+}
+
+/**
+ * ice_sched_move_vsi_to_agg - move VSI to aggregator node
+ * @pi: port information structure
+ * @vsi_handle: software VSI handle
+ * @agg_id: aggregator ID
+ * @tc: TC number
+ *
+ * This function moves a VSI to an aggregator node or its subtree.
+ * Intermediate nodes may be created if required.
+ */
+static enum ice_status
+ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
+			  u8 tc)
+{
+	struct ice_sched_node *vsi_node, *agg_node, *tc_node, *parent;
+	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
+	u32 first_node_teid, vsi_teid;
+	enum ice_status status;
+	u16 num_nodes_added;
+	u8 aggl, vsil, i;
+
+	tc_node = ice_sched_get_tc_node(pi, tc);
+	if (!tc_node)
+		return ICE_ERR_CFG;
+
+	agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+	if (!agg_node)
+		return ICE_ERR_DOES_NOT_EXIST;
+
+	vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+	if (!vsi_node)
+		return ICE_ERR_DOES_NOT_EXIST;
+
+	aggl = ice_sched_get_agg_layer(pi->hw);
+	vsil = ice_sched_get_vsi_layer(pi->hw);
+
+	/* set intermediate node count to 1 between aggregator and VSI layers */
+	for (i = aggl + 1; i < vsil; i++)
+		num_nodes[i] = 1;
+
+	/* Check if the aggregator subtree has any free node to add the VSI */
+	for (i = 0; i < agg_node->num_children; i++) {
+		parent = ice_sched_get_free_vsi_parent(pi->hw,
+						       agg_node->children[i],
+						       num_nodes);
+		if (parent)
+			goto move_nodes;
+	}
+
+	/* add new nodes */
+	parent = agg_node;
+	for (i = aggl + 1; i < vsil; i++) {
+		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
+						      num_nodes[i],
+						      &first_node_teid,
+						      &num_nodes_added);
+		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
+			return ICE_ERR_CFG;
+
+		/* The newly added node can be a new parent for the next
+		 * layer nodes
+		 */
+		if (num_nodes_added)
+			parent = ice_sched_find_node_by_teid(tc_node,
+							     first_node_teid);
+		else
+			parent = parent->children[0];
+
+		if (!parent)
+			return ICE_ERR_CFG;
+	}
+
+move_nodes:
+	vsi_teid = LE32_TO_CPU(vsi_node->info.node_teid);
+	return ice_sched_move_nodes(pi, parent, 1, &vsi_teid);
+}
+
+/**
  * ice_move_all_vsi_to_dflt_agg - move all VSI(s) to default aggregator
  * @pi: port information structure
  * @agg_info: aggregator info
@@ -2114,20 +2363,89 @@ ice_move_all_vsi_to_dflt_agg(struct ice_port_info *pi,
 }
 
 /**
- * ice_rm_agg_cfg_tc - remove aggregator configuration for TC
+ * ice_sched_is_agg_inuse - check whether the aggregator is in use or not
  * @pi: port information structure
- * @agg_info: aggregator ID
- * @tc: TC number
- * @rm_vsi_info: bool value true or false
+ * @node: node pointer
  *
- * This function removes aggregator reference to VSI of given TC. It removes
- * the aggregator configuration completely for requested TC. The caller needs
- * to hold the scheduler lock.
+ * This function checks whether the aggregator is attached with any VSI or not.
  */
-static enum ice_status
-ice_rm_agg_cfg_tc(struct ice_port_info *pi, struct ice_sched_agg_info *agg_info,
-		  u8 tc, bool rm_vsi_info)
-{
+static bool
+ice_sched_is_agg_inuse(struct ice_port_info *pi, struct ice_sched_node *node)
+{
+	u8 vsil, i;
+
+	vsil = ice_sched_get_vsi_layer(pi->hw);
+	if (node->tx_sched_layer < vsil - 1) {
+		for (i = 0; i < node->num_children; i++)
+			if (ice_sched_is_agg_inuse(pi, node->children[i]))
+				return true;
+		return false;
+	} else {
+		return node->num_children ? true : false;
+	}
+}
+
+/**
+ * ice_sched_rm_agg_cfg - remove the aggregator node
+ * @pi: port information structure
+ * @agg_id: aggregator ID
+ * @tc: TC number
+ *
+ * This function removes the aggregator node and intermediate nodes if any
+ * from the given TC
+ */
+static enum ice_status
+ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
+{
+	struct ice_sched_node *tc_node, *agg_node;
+	struct ice_hw *hw = pi->hw;
+
+	tc_node = ice_sched_get_tc_node(pi, tc);
+	if (!tc_node)
+		return ICE_ERR_CFG;
+
+	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	if (!agg_node)
+		return ICE_ERR_DOES_NOT_EXIST;
+
+	/* Can't remove the aggregator node if it has children */
+	if (ice_sched_is_agg_inuse(pi, agg_node))
+		return ICE_ERR_IN_USE;
+
+	/* need to remove the whole subtree if aggregator node is the
+	 * only child.
+	 */
+	while (agg_node->tx_sched_layer > hw->sw_entry_point_layer) {
+		struct ice_sched_node *parent = agg_node->parent;
+
+		if (!parent)
+			return ICE_ERR_CFG;
+
+		if (parent->num_children > 1)
+			break;
+
+		agg_node = parent;
+	}
+
+	ice_free_sched_node(pi, agg_node);
+	return ICE_SUCCESS;
+}
+
+/**
+ * ice_rm_agg_cfg_tc - remove aggregator configuration for TC
+ * @pi: port information structure
+ * @agg_info: aggregator ID
+ * @tc: TC number
+ * @rm_vsi_info: bool value true or false
+ *
+ * This function removes aggregator reference to VSI of given TC. It removes
+ * the aggregator configuration completely for requested TC. The caller needs
+ * to hold the scheduler lock.
+ */
+static enum ice_status
+ice_rm_agg_cfg_tc(struct ice_port_info *pi, struct ice_sched_agg_info *agg_info,
+		  u8 tc, bool rm_vsi_info)
+{
 	enum ice_status status = ICE_SUCCESS;
 
 	/* If nothing to remove - return success */
@@ -2172,6 +2490,89 @@ ice_save_agg_tc_bitmap(struct ice_port_info *pi, u32 agg_id,
 }
 
 /**
+ * ice_sched_add_agg_cfg - create an aggregator node
+ * @pi: port information structure
+ * @agg_id: aggregator ID
+ * @tc: TC number
+ *
+ * This function creates an aggregator node and intermediate nodes if required
+ * for the given TC
+ */
+static enum ice_status
+ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
+{
+	struct ice_sched_node *parent, *agg_node, *tc_node;
+	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
+	enum ice_status status = ICE_SUCCESS;
+	struct ice_hw *hw = pi->hw;
+	u32 first_node_teid;
+	u16 num_nodes_added;
+	u8 i, aggl;
+
+	tc_node = ice_sched_get_tc_node(pi, tc);
+	if (!tc_node)
+		return ICE_ERR_CFG;
+
+	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	/* Does Agg node already exist ? */
+	if (agg_node)
+		return status;
+
+	aggl = ice_sched_get_agg_layer(hw);
+
+	/* need one node in Agg layer */
+	num_nodes[aggl] = 1;
+
+	/* Check whether the intermediate nodes have space to add the
+	 * new aggregator. If they are full, then SW needs to allocate a new
+	 * intermediate node on those layers
+	 */
+	for (i = hw->sw_entry_point_layer; i < aggl; i++) {
+		parent = ice_sched_get_first_node(hw, tc_node, i);
+
+		/* scan all the siblings */
+		while (parent) {
+			if (parent->num_children < hw->max_children[i])
+				break;
+			parent = parent->sibling;
+		}
+
+		/* all the nodes are full, reserve one for this layer */
+		if (!parent)
+			num_nodes[i]++;
+	}
+
+	/* add the aggregator node */
+	parent = tc_node;
+	for (i = hw->sw_entry_point_layer; i <= aggl; i++) {
+		if (!parent)
+			return ICE_ERR_CFG;
+
+		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
+						      num_nodes[i],
+						      &first_node_teid,
+						      &num_nodes_added);
+		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
+			return ICE_ERR_CFG;
+
+		/* The newly added node can be a new parent for the next
+		 * layer nodes
+		 */
+		if (num_nodes_added) {
+			parent = ice_sched_find_node_by_teid(tc_node,
+							     first_node_teid);
+			/* register aggregator ID with the aggregator node */
+			if (parent && i == aggl)
+				parent->agg_id = agg_id;
+		} else {
+			parent = parent->children[0];
+		}
+	}
+
+	return ICE_SUCCESS;
+}
+
+/**
  * ice_sched_cfg_agg - configure aggregator node
  * @pi: port information structure
  * @agg_id: aggregator ID
@@ -2406,6 +2807,109 @@ ice_sched_assoc_vsi_to_agg(struct ice_port_info *pi, u32 agg_id,
 }
 
 /**
+ * ice_sched_rm_unused_rl_prof - remove unused RL profile
+ * @pi: port information structure
+ *
+ * This function removes unused rate limit profiles from the HW and
+ * SW DB. The caller needs to hold scheduler lock.
+ */
+static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi)
+{
+	u8 ln;
+
+	for (ln = 0; ln < pi->hw->num_tx_sched_layers; ln++) {
+		struct ice_aqc_rl_profile_info *rl_prof_elem;
+		struct ice_aqc_rl_profile_info *rl_prof_tmp;
+
+		LIST_FOR_EACH_ENTRY_SAFE(rl_prof_elem, rl_prof_tmp,
+					 &pi->rl_prof_list[ln],
+					 ice_aqc_rl_profile_info, list_entry) {
+			if (!ice_sched_del_rl_profile(pi->hw, rl_prof_elem))
+				ice_debug(pi->hw, ICE_DBG_SCHED,
+					  "Removed rl profile\n");
+		}
+	}
+}
+
+/**
+ * ice_sched_update_elem - update element
+ * @hw: pointer to the HW struct
+ * @node: pointer to node
+ * @info: node info to update
+ *
+ * It updates the HW DB, and local SW DB of node. It updates the scheduling
+ * parameters of node from argument info data buffer (Info->data buf) and
+ * returns success or error on config sched element failure. The caller
+ * needs to hold scheduler lock.
+ */
+static enum ice_status
+ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node,
+		      struct ice_aqc_txsched_elem_data *info)
+{
+	struct ice_aqc_conf_elem buf;
+	enum ice_status status;
+	u16 elem_cfgd = 0;
+	u16 num_elems = 1;
+
+	buf.generic[0] = *info;
+	/* Parent TEID is reserved field in this aq call */
+	buf.generic[0].parent_teid = 0;
+	/* Element type is reserved field in this aq call */
+	buf.generic[0].data.elem_type = 0;
+	/* Flags is reserved field in this aq call */
+	buf.generic[0].data.flags = 0;
+
+	/* Update HW DB */
+	/* Configure element node */
+	status = ice_aq_cfg_sched_elems(hw, num_elems, &buf, sizeof(buf),
+					&elem_cfgd, NULL);
+	if (status || elem_cfgd != num_elems) {
+		ice_debug(hw, ICE_DBG_SCHED, "Config sched elem error\n");
+		return ICE_ERR_CFG;
+	}
+
+	/* Config success case */
+	/* Now update local SW DB */
+	/* Only copy the data portion of info buffer */
+	node->info.data = info->data;
+	return status;
+}
+
+/**
+ * ice_sched_cfg_node_bw_alloc - configure node BW weight/alloc params
+ * @hw: pointer to the HW struct
+ * @node: sched node to configure
+ * @rl_type: rate limit type CIR, EIR, or shared
+ * @bw_alloc: BW weight/allocation
+ *
+ * This function configures node element's BW allocation.
+ */
+static enum ice_status
+ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node,
+			    enum ice_rl_type rl_type, u8 bw_alloc)
+{
+	struct ice_aqc_txsched_elem_data buf;
+	struct ice_aqc_txsched_elem *data;
+	enum ice_status status;
+
+	buf = node->info;
+	data = &buf.data;
+	if (rl_type == ICE_MIN_BW) {
+		data->valid_sections |= ICE_AQC_ELEM_VALID_CIR;
+		data->cir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
+	} else if (rl_type == ICE_MAX_BW) {
+		data->valid_sections |= ICE_AQC_ELEM_VALID_EIR;
+		data->eir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
+	} else {
+		return ICE_ERR_PARAM;
+	}
+
+	/* Configure element */
+	status = ice_sched_update_elem(hw, node, &buf);
+	return status;
+}
+
+/**
  * ice_move_vsi_to_agg - moves VSI to new or default aggregator
  * @pi: port information structure
  * @agg_id: aggregator ID
@@ -3372,110 +3876,6 @@ ice_sched_add_rl_profile(struct ice_port_info *pi,
 }
 
 /**
- * ice_sched_del_rl_profile - remove rl profile
- * @hw: pointer to the hw struct
- * @rl_info: rate limit profile information
- *
- * If the profile id is not referenced anymore, it removes profile id with
- * its associated parameters from hw db,and locally. The caller needs to
- * hold scheduler lock.
- */
-enum ice_status
-ice_sched_del_rl_profile(struct ice_hw *hw,
-			 struct ice_aqc_rl_profile_info *rl_info)
-{
-	struct ice_aqc_rl_profile_generic_elem *buf;
-	u16 num_profiles_removed;
-	enum ice_status status;
-	u16 num_profiles = 1;
-
-	if (rl_info->prof_id_ref != 0)
-		return ICE_ERR_IN_USE;
-
-	/* Safe to remove profile id */
-	buf = (struct ice_aqc_rl_profile_generic_elem *)
-		&rl_info->profile;
-	status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf),
-					  &num_profiles_removed, NULL);
-	if (status || num_profiles_removed != num_profiles)
-		return ICE_ERR_CFG;
-
-	/* Delete stale entry now */
-	LIST_DEL(&rl_info->list_entry);
-	ice_free(hw, rl_info);
-	return status;
-}
-
-/**
- * ice_sched_rm_unused_rl_prof - remove unused rl profile
- * @pi: port information structure
- *
- * This function removes unused rate limit profiles from the hw and
- * SW DB. The caller needs to hold scheduler lock.
- */
-void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi)
-{
-	u8 ln;
-
-	for (ln = 0; ln < pi->hw->num_tx_sched_layers; ln++) {
-		struct ice_aqc_rl_profile_info *rl_prof_elem;
-		struct ice_aqc_rl_profile_info *rl_prof_tmp;
-
-		LIST_FOR_EACH_ENTRY_SAFE(rl_prof_elem, rl_prof_tmp,
-					 &pi->rl_prof_list[ln],
-					 ice_aqc_rl_profile_info, list_entry) {
-			if (!ice_sched_del_rl_profile(pi->hw, rl_prof_elem))
-				ice_debug(pi->hw, ICE_DBG_SCHED,
-					  "Removed rl profile\n");
-		}
-	}
-}
-
-/**
- * ice_sched_update_elem - update element
- * @hw: pointer to the hw struct
- * @node: pointer to node
- * @info: node info to update
- *
- * It updates the HW DB, and local SW DB of node. It updates the scheduling
- * parameters of node from argument info data buffer (Info->data buf) and
- * returns success or error on config sched element failure. The caller
- * needs to hold scheduler lock.
- */
-static enum ice_status
-ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node,
-		      struct ice_aqc_txsched_elem_data *info)
-{
-	struct ice_aqc_conf_elem buf;
-	enum ice_status status;
-	u16 elem_cfgd = 0;
-	u16 num_elems = 1;
-
-	buf.generic[0] = *info;
-	/* Parent teid is reserved field in this aq call */
-	buf.generic[0].parent_teid = 0;
-	/* Element type is reserved field in this aq call */
-	buf.generic[0].data.elem_type = 0;
-	/* Flags is reserved field in this aq call */
-	buf.generic[0].data.flags = 0;
-
-	/* Update HW DB */
-	/* Configure element node */
-	status = ice_aq_cfg_sched_elems(hw, num_elems, &buf, sizeof(buf),
-					&elem_cfgd, NULL);
-	if (status || elem_cfgd != num_elems) {
-		ice_debug(hw, ICE_DBG_SCHED, "Config sched elem error\n");
-		return ICE_ERR_CFG;
-	}
-
-	/* Config success case */
-	/* Now update local SW DB */
-	/* Only copy the data portion of info buffer */
-	node->info.data = info->data;
-	return status;
-}
-
-/**
  * ice_sched_cfg_node_bw_lmt - configure node sched params
  * @hw: pointer to the HW struct
  * @node: sched node to configure
@@ -3841,7 +4241,7 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
  * It updates node's BW limit parameters like BW RL profile ID of type CIR,
  * EIR, or SRL. The caller needs to hold scheduler lock.
  */
-enum ice_status
+static enum ice_status
 ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node,
 			  enum ice_rl_type rl_type, u32 bw)
 {
@@ -4588,7 +4988,7 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
 
 /**
  * ice_sched_cfg_sibl_node_prio - configure node sibling priority
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @node: sched node to configure
  * @priority: sibling priority
  *
@@ -4617,406 +5017,6 @@ ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
 }
 
 /**
- * ice_sched_cfg_node_bw_alloc - configure node bw weight/alloc params
- * @hw: pointer to the hw struct
- * @node: sched node to configure
- * @rl_type: rate limit type cir, eir, or shared
- * @bw_alloc: bw weight/allocation
- *
- * This function configures node element's bw allocation.
- */
-enum ice_status
-ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node,
-			    enum ice_rl_type rl_type, u8 bw_alloc)
-{
-	struct ice_aqc_txsched_elem_data buf;
-	struct ice_aqc_txsched_elem *data;
-	enum ice_status status;
-
-	buf = node->info;
-	data = &buf.data;
-	if (rl_type == ICE_MIN_BW) {
-		data->valid_sections |= ICE_AQC_ELEM_VALID_CIR;
-		data->cir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
-	} else if (rl_type == ICE_MAX_BW) {
-		data->valid_sections |= ICE_AQC_ELEM_VALID_EIR;
-		data->eir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
-	} else {
-		return ICE_ERR_PARAM;
-	}
-
-	/* Configure element */
-	status = ice_sched_update_elem(hw, node, &buf);
-	return status;
-}
-
-/**
- * ice_sched_add_agg_cfg - create an aggregator node
- * @pi: port information structure
- * @agg_id: aggregator id
- * @tc: TC number
- *
- * This function creates an aggregator node and intermediate nodes if required
- * for the given TC
- */
-enum ice_status
-ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
-{
-	struct ice_sched_node *parent, *agg_node, *tc_node;
-	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
-	enum ice_status status = ICE_SUCCESS;
-	struct ice_hw *hw = pi->hw;
-	u32 first_node_teid;
-	u16 num_nodes_added;
-	u8 i, aggl;
-
-	tc_node = ice_sched_get_tc_node(pi, tc);
-	if (!tc_node)
-		return ICE_ERR_CFG;
-
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
-	/* Does Agg node already exist ? */
-	if (agg_node)
-		return status;
-
-	aggl = ice_sched_get_agg_layer(hw);
-
-	/* need one node in Agg layer */
-	num_nodes[aggl] = 1;
-
-	/* Check whether the intermediate nodes have space to add the
-	 * new agg. If they are full, then SW needs to allocate a new
-	 * intermediate node on those layers
-	 */
-	for (i = hw->sw_entry_point_layer; i < aggl; i++) {
-		parent = ice_sched_get_first_node(hw, tc_node, i);
-
-		/* scan all the siblings */
-		while (parent) {
-			if (parent->num_children < hw->max_children[i])
-				break;
-			parent = parent->sibling;
-		}
-
-		/* all the nodes are full, reserve one for this layer */
-		if (!parent)
-			num_nodes[i]++;
-	}
-
-	/* add the agg node */
-	parent = tc_node;
-	for (i = hw->sw_entry_point_layer; i <= aggl; i++) {
-		if (!parent)
-			return ICE_ERR_CFG;
-
-		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
-						      num_nodes[i],
-						      &first_node_teid,
-						      &num_nodes_added);
-		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
-			return ICE_ERR_CFG;
-
-		/* The newly added node can be a new parent for the next
-		 * layer nodes
-		 */
-		if (num_nodes_added) {
-			parent = ice_sched_find_node_by_teid(tc_node,
-							     first_node_teid);
-			/* register the aggregator id with the agg node */
-			if (parent && i == aggl)
-				parent->agg_id = agg_id;
-		} else {
-			parent = parent->children[0];
-		}
-	}
-
-	return ICE_SUCCESS;
-}
-
-/**
- * ice_sched_is_agg_inuse - check whether the agg is in use or not
- * @pi: port information structure
- * @node: node pointer
- *
- * This function checks whether the agg is attached with any vsi or not.
- */
-static bool
-ice_sched_is_agg_inuse(struct ice_port_info *pi, struct ice_sched_node *node)
-{
-	u8 vsil, i;
-
-	vsil = ice_sched_get_vsi_layer(pi->hw);
-	if (node->tx_sched_layer < vsil - 1) {
-		for (i = 0; i < node->num_children; i++)
-			if (ice_sched_is_agg_inuse(pi, node->children[i]))
-				return true;
-		return false;
-	} else {
-		return node->num_children ? true : false;
-	}
-}
-
-/**
- * ice_sched_rm_agg_cfg - remove the aggregator node
- * @pi: port information structure
- * @agg_id: aggregator id
- * @tc: TC number
- *
- * This function removes the aggregator node and intermediate nodes if any
- * from the given TC
- */
-enum ice_status
-ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
-{
-	struct ice_sched_node *tc_node, *agg_node;
-	struct ice_hw *hw = pi->hw;
-
-	tc_node = ice_sched_get_tc_node(pi, tc);
-	if (!tc_node)
-		return ICE_ERR_CFG;
-
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
-	if (!agg_node)
-		return ICE_ERR_DOES_NOT_EXIST;
-
-	/* Can't remove the agg node if it has children */
-	if (ice_sched_is_agg_inuse(pi, agg_node))
-		return ICE_ERR_IN_USE;
-
-	/* need to remove the whole subtree if agg node is the
-	 * only child.
-	 */
-	while (agg_node->tx_sched_layer > hw->sw_entry_point_layer) {
-		struct ice_sched_node *parent = agg_node->parent;
-
-		if (!parent)
-			return ICE_ERR_CFG;
-
-		if (parent->num_children > 1)
-			break;
-
-		agg_node = parent;
-	}
-
-	ice_free_sched_node(pi, agg_node);
-	return ICE_SUCCESS;
-}
-
-/**
- * ice_sched_get_free_vsi_parent - Find a free parent node in agg subtree
- * @hw: pointer to the hw struct
- * @node: pointer to a child node
- * @num_nodes: num nodes count array
- *
- * This function walks through the aggregator subtree to find a free parent
- * node
- */
-static struct ice_sched_node *
-ice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node,
-			      u16 *num_nodes)
-{
-	u8 l = node->tx_sched_layer;
-	u8 vsil, i;
-
-	vsil = ice_sched_get_vsi_layer(hw);
-
-	/* Is it VSI parent layer ? */
-	if (l == vsil - 1)
-		return (node->num_children < hw->max_children[l]) ? node : NULL;
-
-	/* We have intermediate nodes. Let's walk through the subtree. If the
-	 * intermediate node has space to add a new node then clear the count
-	 */
-	if (node->num_children < hw->max_children[l])
-		num_nodes[l] = 0;
-	/* The below recursive call is intentional and wouldn't go more than
-	 * 2 or 3 iterations.
-	 */
-
-	for (i = 0; i < node->num_children; i++) {
-		struct ice_sched_node *parent;
-
-		parent = ice_sched_get_free_vsi_parent(hw, node->children[i],
-						       num_nodes);
-		if (parent)
-			return parent;
-	}
-
-	return NULL;
-}
-
-/**
- * ice_sched_update_new_parent - update the new parent in SW DB
- * @new_parent: pointer to a new parent node
- * @node: pointer to a child node
- *
- * This function removes the child from the old parent and adds it to a new
- * parent
- */
-static void
-ice_sched_update_parent(struct ice_sched_node *new_parent,
-			struct ice_sched_node *node)
-{
-	struct ice_sched_node *old_parent;
-	u8 i, j;
-
-	old_parent = node->parent;
-
-	/* update the old parent children */
-	for (i = 0; i < old_parent->num_children; i++)
-		if (old_parent->children[i] == node) {
-			for (j = i + 1; j < old_parent->num_children; j++)
-				old_parent->children[j - 1] =
-					old_parent->children[j];
-			old_parent->num_children--;
-			break;
-		}
-
-	/* now move the node to a new parent */
-	new_parent->children[new_parent->num_children++] = node;
-	node->parent = new_parent;
-	node->info.parent_teid = new_parent->info.node_teid;
-}
-
-/**
- * ice_sched_move_nodes - move child nodes to a given parent
- * @pi: port information structure
- * @parent: pointer to parent node
- * @num_items: number of child nodes to be moved
- * @list: pointer to child node teids
- *
- * This function move the child nodes to a given parent.
- */
-static enum ice_status
-ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
-		     u16 num_items, u32 *list)
-{
-	struct ice_aqc_move_elem *buf;
-	struct ice_sched_node *node;
-	enum ice_status status = ICE_SUCCESS;
-	struct ice_hw *hw;
-	u16 grps_movd = 0;
-	u8 i;
-
-	hw = pi->hw;
-
-	if (!parent || !num_items)
-		return ICE_ERR_PARAM;
-
-	/* Does parent have enough space */
-	if (parent->num_children + num_items >=
-	    hw->max_children[parent->tx_sched_layer])
-		return ICE_ERR_AQ_FULL;
-
-	buf = (struct ice_aqc_move_elem *) ice_malloc(hw, sizeof(*buf));
-	if (!buf)
-		return ICE_ERR_NO_MEMORY;
-
-	for (i = 0; i < num_items; i++) {
-		node = ice_sched_find_node_by_teid(pi->root, list[i]);
-		if (!node) {
-			status = ICE_ERR_PARAM;
-			goto move_err_exit;
-		}
-
-		buf->hdr.src_parent_teid = node->info.parent_teid;
-		buf->hdr.dest_parent_teid = parent->info.node_teid;
-		buf->teid[0] = node->info.node_teid;
-		buf->hdr.num_elems = CPU_TO_LE16(1);
-		status = ice_aq_move_sched_elems(hw, 1, buf, sizeof(*buf),
-						 &grps_movd, NULL);
-		if (status && grps_movd != 1) {
-			status = ICE_ERR_CFG;
-			goto move_err_exit;
-		}
-
-		/* update the SW DB */
-		ice_sched_update_parent(parent, node);
-	}
-
-move_err_exit:
-	ice_free(hw, buf);
-	return status;
-}
-
-/**
- * ice_sched_move_vsi_to_agg - move VSI to aggregator node
- * @pi: port information structure
- * @vsi_handle: software VSI handle
- * @agg_id: aggregator id
- * @tc: TC number
- *
- * This function moves a VSI to an aggregator node or its subtree.
- * Intermediate nodes may be created if required.
- */
-enum ice_status
-ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
-			  u8 tc)
-{
-	struct ice_sched_node *vsi_node, *agg_node, *tc_node, *parent;
-	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
-	u32 first_node_teid, vsi_teid;
-	enum ice_status status;
-	u16 num_nodes_added;
-	u8 aggl, vsil, i;
-
-	tc_node = ice_sched_get_tc_node(pi, tc);
-	if (!tc_node)
-		return ICE_ERR_CFG;
-
-	agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
-	if (!agg_node)
-		return ICE_ERR_DOES_NOT_EXIST;
-
-	vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
-	if (!vsi_node)
-		return ICE_ERR_DOES_NOT_EXIST;
-
-	aggl = ice_sched_get_agg_layer(pi->hw);
-	vsil = ice_sched_get_vsi_layer(pi->hw);
-
-	/* initialize intermediate node count to 1 between agg and VSI layers */
-	for (i = aggl + 1; i < vsil; i++)
-		num_nodes[i] = 1;
-
-	/* Check whether the agg subtree has any free node to add the VSI */
-	for (i = 0; i < agg_node->num_children; i++) {
-		parent = ice_sched_get_free_vsi_parent(pi->hw,
-						       agg_node->children[i],
-						       num_nodes);
-		if (parent)
-			goto move_nodes;
-	}
-
-	/* add new nodes */
-	parent = agg_node;
-	for (i = aggl + 1; i < vsil; i++) {
-		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
-						      num_nodes[i],
-						      &first_node_teid,
-						      &num_nodes_added);
-		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
-			return ICE_ERR_CFG;
-
-		/* The newly added node can be a new parent for the next
-		 * layer nodes
-		 */
-		if (num_nodes_added)
-			parent = ice_sched_find_node_by_teid(tc_node,
-							     first_node_teid);
-		else
-			parent = parent->children[0];
-
-		if (!parent)
-			return ICE_ERR_CFG;
-	}
-
-move_nodes:
-	vsi_teid = LE32_TO_CPU(vsi_node->info.node_teid);
-	return ice_sched_move_nodes(pi, parent, 1, &vsi_teid);
-}
-
-/**
  * ice_cfg_rl_burst_size - Set burst size value
  * @hw: pointer to the HW struct
  * @bytes: burst size in bytes
drivers/net/ice/base/ice_sched.h +0 -24
index 61fa6a85b..09de765ff 100644
@@ -76,10 +76,6 @@ ice_aq_cfg_l2_node_cgd(struct ice_hw *hw, u16 num_nodes,
 		       struct ice_aqc_cfg_l2_node_cgd_data *buf, u16 buf_size,
 		       struct ice_sq_cd *cd);
 enum ice_status
-ice_aq_move_sched_elems(struct ice_hw *hw, u16 grps_req,
-			struct ice_aqc_move_elem *buf, u16 buf_size,
-			u16 *grps_movd, struct ice_sq_cd *cd);
-enum ice_status
 ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
 			 struct ice_aqc_get_elem *buf, u16 buf_size,
 			 u16 *elems_ret, struct ice_sq_cd *cd);
@@ -109,9 +105,6 @@ ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
 		  u8 owner, bool enable);
 enum ice_status ice_rm_vsi_lan_cfg(struct ice_port_info *pi, u16 vsi_handle);
 struct ice_sched_node *
-ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
-		       u32 agg_id);
-struct ice_sched_node *
 ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
 		       u16 vsi_handle);
 bool ice_sched_is_tree_balanced(struct ice_hw *hw, struct ice_sched_node *node);
@@ -177,9 +170,6 @@ bool
 ice_sched_find_node_in_subtree(struct ice_hw *hw, struct ice_sched_node *base,
 			       struct ice_sched_node *node);
 enum ice_status
-ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node,
-			  enum ice_rl_type rl_type, u32 bw);
-enum ice_status
 ice_sched_set_agg_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle);
 enum ice_status
 ice_sched_set_node_bw_lmt_per_tc(struct ice_port_info *pi, u32 id,
@@ -193,18 +183,4 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw);
 enum ice_status
 ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
 			     u8 priority);
-enum ice_status
-ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node,
-			    enum ice_rl_type rl_type, u8 bw_alloc);
-enum ice_status
-ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc);
-enum ice_status
-ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc);
-enum ice_status
-ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
-			  u8 tc);
-enum ice_status
-ice_sched_del_rl_profile(struct ice_hw *hw,
-			 struct ice_aqc_rl_profile_info *rl_info);
-void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi);
 #endif /* _ICE_SCHED_H_ */
Signature · 1 line
2.13.6
author
#21 lore raw

PATCH 19/37 net/ice/base: enable VSI queue context

In reply to Qi Zhang

The patch added to retrieve the queue context and update the queue handle for lan queues.

---
 drivers/net/ice/base/ice_common.c | 60 ++++++++++++++++++++++++++++++++++++---
 drivers/net/ice/base/ice_common.h | 11 +++----
 drivers/net/ice/ice_rxtx.c        | 11 +++++--
 3 files changed, 70 insertions(+), 12 deletions(-)
drivers/net/ice/base/ice_common.c +56 -4
index e0fe06e9c..f5cbd47c3 100644
@@ -3512,10 +3512,35 @@ ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info)
 }
 
 /**
+ * ice_get_lan_q_ctx - get the LAN queue context for the given VSI and TC
+ * @hw: pointer to the HW struct
+ * @vsi_handle: software VSI handle
+ * @tc: TC number
+ * @q_handle: software queue handle
+ */
+static struct ice_q_ctx *
+ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle)
+{
+	struct ice_vsi_ctx *vsi;
+	struct ice_q_ctx *q_ctx;
+
+	vsi = ice_get_vsi_ctx(hw, vsi_handle);
+	if (!vsi)
+		return NULL;
+	if (q_handle >= vsi->num_lan_q_entries[tc])
+		return NULL;
+	if (!vsi->lan_q_ctx[tc])
+		return NULL;
+	q_ctx = vsi->lan_q_ctx[tc];
+	return &q_ctx[q_handle];
+}
+
+/**
  * ice_ena_vsi_txq
  * @pi: port information structure
  * @vsi_handle: software VSI handle
  * @tc: TC number
+ * @q_handle: software queue handle
  * @num_qgrps: Number of added queue groups
  * @buf: list of queue groups to be added
  * @buf_size: size of buffer for indirect command
@@ -3524,12 +3549,13 @@ ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info)
  * This function adds one LAN queue
  */
 enum ice_status
-ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
-		struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
+ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
+		u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
 		struct ice_sq_cd *cd)
 {
 	struct ice_aqc_txsched_elem_data node = { 0 };
 	struct ice_sched_node *parent;
+	struct ice_q_ctx *q_ctx;
 	enum ice_status status;
 	struct ice_hw *hw;
 
@@ -3546,6 +3572,14 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
 
 	ice_acquire_lock(&pi->sched_lock);
 
+	q_ctx = ice_get_lan_q_ctx(hw, vsi_handle, tc, q_handle);
+	if (!q_ctx) {
+		ice_debug(hw, ICE_DBG_SCHED, "Enaq: invalid queue handle %d\n",
+			  q_handle);
+		status = ICE_ERR_PARAM;
+		goto ena_txq_exit;
+	}
+
 	/* find a parent node */
 	parent = ice_sched_get_free_qparent(pi, vsi_handle, tc,
 					    ICE_SCHED_NODE_OWNER_LAN);
@@ -3580,6 +3614,7 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
 
 	node.node_teid = buf->txqs[0].q_teid;
 	node.data.elem_type = ICE_AQC_ELEM_TYPE_LEAF;
+	q_ctx->q_handle = q_handle;
 
 	/* add a leaf node into schduler tree queue layer */
 	status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node);
@@ -3592,7 +3627,10 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
 /**
  * ice_dis_vsi_txq
  * @pi: port information structure
+ * @vsi_handle: software VSI handle
+ * @tc: TC number
  * @num_queues: number of queues
+ * @q_handles: pointer to software queue handle array
  * @q_ids: pointer to the q_id array
  * @q_teids: pointer to queue node teids
  * @rst_src: if called due to reset, specifies the reset source
@@ -3602,12 +3640,14 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
  * This function removes queues and their corresponding nodes in SW DB
  */
 enum ice_status
-ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
-		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
+ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
+		u16 *q_handles, u16 *q_ids, u32 *q_teids,
+		enum ice_disq_rst_src rst_src, u16 vmvf_num,
 		struct ice_sq_cd *cd)
 {
 	enum ice_status status = ICE_ERR_DOES_NOT_EXIST;
 	struct ice_aqc_dis_txq_item qg_list;
+	struct ice_q_ctx *q_ctx;
 	u16 i;
 
 	if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
@@ -3630,6 +3670,17 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		node = ice_sched_find_node_by_teid(pi->root, q_teids[i]);
 		if (!node)
 			continue;
+		q_ctx = ice_get_lan_q_ctx(pi->hw, vsi_handle, tc, q_handles[i]);
+		if (!q_ctx) {
+			ice_debug(pi->hw, ICE_DBG_SCHED, "invalid queue handle%d\n",
+				  q_handles[i]);
+			continue;
+		}
+		if (q_ctx->q_handle != q_handles[i]) {
+			ice_debug(pi->hw, ICE_DBG_SCHED, "Err:handles %d %d\n",
+				  q_ctx->q_handle, q_handles[i]);
+			continue;
+		}
 		qg_list.parent_teid = node->info.parent_teid;
 		qg_list.num_qs = 1;
 		qg_list.q_id[0] = CPU_TO_LE16(q_ids[i]);
@@ -3640,6 +3691,7 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		if (status != ICE_SUCCESS)
 			break;
 		ice_free_sched_node(pi, node);
+		q_ctx->q_handle = ICE_INVAL_Q_HANDLE;
 	}
 	ice_release_lock(&pi->sched_lock);
 	return status;
drivers/net/ice/base/ice_common.h +6 -5
index 63f4a5ebe..72560fbbf 100644
@@ -157,15 +157,16 @@ ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 enum ice_status
 ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info);
 enum ice_status
-ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
-		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
-		struct ice_sq_cd *cmd_details);
+ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
+		u16 *q_handle, u16 *q_ids, u32 *q_teids,
+		enum ice_disq_rst_src rst_src, u16 vmvf_num,
+		struct ice_sq_cd *cd);
 enum ice_status
 ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
 		u16 *max_lanqs);
 enum ice_status
-ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
-		struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
+ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
+		u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
 		struct ice_sq_cd *cd);
 enum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
 void ice_replay_post(struct ice_hw *hw);
drivers/net/ice/ice_rxtx.c +8 -3
index c794ee861..b65bb4a51 100644
@@ -453,7 +453,8 @@ ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	/* Init the Tx tail register*/
 	ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
 
-	err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, 1, &txq_elem,
+	/* Fix me, we assume TC always 0 here */
+	err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, 0, 1, &txq_elem,
 			      sizeof(txq_elem), NULL);
 	if (err) {
 		PMD_DRV_LOG(ERR, "Failed to add lan txq");
@@ -528,9 +529,12 @@ ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct ice_tx_queue *txq;
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct ice_vsi *vsi = pf->main_vsi;
 	enum ice_status status;
 	uint16_t q_ids[1];
 	uint32_t q_teids[1];
+	uint16_t q_handle = 0;
 
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
 		PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
@@ -548,8 +552,9 @@ ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	q_ids[0] = txq->reg_idx;
 	q_teids[0] = txq->q_teid;
 
-	status = ice_dis_vsi_txq(hw->port_info, 1, q_ids, q_teids,
-				 ICE_NO_RESET, 0, NULL);
+	/* Fix me, we assume TC always 0 here */
+	status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
+				q_ids, q_teids, ICE_NO_RESET, 0, NULL);
 	if (status != ICE_SUCCESS) {
 		PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
 		return -EINVAL;
Signature · 1 line
2.13.6
author
#22 lore raw

PATCH 20/37 net/ice/base: ensure only valid bits are set

In reply to Qi Zhang

In the ice_aq_set_phy_cfg AQ command, the 16.4 bit is reserved. This patch will make sure that this bit will never be set to 1.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 1 +
 drivers/net/ice/base/ice_common.c     | 9 +++++++++
 2 files changed, 10 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +1 -0
index ca3d40c8b..70cd0604b 100644
@@ -1327,6 +1327,7 @@ struct ice_aqc_set_phy_cfg_data {
 	__le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */
 	__le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */
 	u8 caps;
+#define ICE_AQ_PHY_ENA_VALID_MASK	MAKEMASK(0xef, 0)
 #define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY	BIT(0)
 #define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY	BIT(1)
 #define ICE_AQ_PHY_ENA_LOW_POWER	BIT(2)
drivers/net/ice/base/ice_common.c +9 -0
index f5cbd47c3..1c381b5e2 100644
@@ -2351,6 +2351,15 @@ ice_aq_set_phy_cfg(struct ice_hw *hw, u8 lport,
 	if (!cfg)
 		return ICE_ERR_PARAM;
 
+	/* Ensure that only valid bits of cfg->caps can be turned on. */
+	if (cfg->caps & ~ICE_AQ_PHY_ENA_VALID_MASK) {
+		ice_debug(hw, ICE_DBG_PHY,
+			  "Invalid bit is set in ice_aqc_set_phy_cfg_data->caps : 0x%x\n",
+			  cfg->caps);
+
+		cfg->caps &= ICE_AQ_PHY_ENA_VALID_MASK;
+	}
+
 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_phy_cfg);
 	desc.params.set_phy.lport_num = lport;
 	desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
Signature · 1 line
2.13.6
author
#23 lore raw

PATCH 21/37 net/ice/base: enhance get link status command

In reply to Qi Zhang

Extend the functionality of the admin queue command by including additional status and ID bits to improve link topology configuration.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ice/base/ice_adminq_cmd.h +6 -1
index 70cd0604b..cb1e1ca1a 100644
@@ -1399,7 +1399,12 @@ struct ice_aqc_get_link_status_data {
 #define ICE_AQ_LINK_TOPO_CONFLICT	BIT(0)
 #define ICE_AQ_LINK_MEDIA_CONFLICT	BIT(1)
 #define ICE_AQ_LINK_TOPO_CORRUPT	BIT(2)
-	u8 reserved1;
+#define ICE_AQ_LINK_TOPO_UNREACH_PRT	BIT(4)
+#define ICE_AQ_LINK_TOPO_UNDRUTIL_PRT	BIT(5)
+#define ICE_AQ_LINK_TOPO_UNDRUTIL_MEDIA	BIT(6)
+#define ICE_AQ_LINK_TOPO_UNSUPP_MEDIA	BIT(7)
+	u8 link_cfg_err;
+#define ICE_AQ_LINK_CFG_ERR		BIT(0)
 	u8 link_info;
 #define ICE_AQ_LINK_UP			BIT(0)	/* Link Status */
 #define ICE_AQ_LINK_FAULT		BIT(1)
Signature · 1 line
2.13.6
author
#24 lore raw

PATCH 22/37 net/ice/base: add RSS key related macro and structures

In reply to Qi Zhang

Add define for 52 byte RSS hash key size, and add struct ice_aqc_get_set_rss_keys comments regarding setting 40 bytes and 52 byte hash key.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +13 -0
index cb1e1ca1a..ed7dfae8c 100644
@@ -1593,7 +1593,20 @@ struct ice_aqc_get_set_rss_key {
 
 #define ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE	0x28
 #define ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE	0xC
+#define ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE \
+				(ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE + \
+				 ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE)
 
+/**
+ * struct ice_aqc_get_set_rss_keys - Get/Set RSS hash key command buffer
+ * @standard_rss_key: 40 most significant bytes of hash key
+ * @extended_hash_key: 12 least significant bytes of hash key
+ *
+ * Set/Get 40 byte hash key using standard_rss_key field, and set
+ * extended_hash_key field to zero. Set/Get 52 byte hash key using
+ * standard_rss_key field for 40 most significant bytes and the
+ * extended_hash_key field for the 12 least significant bytes of hash key.
+ */
 struct ice_aqc_get_set_rss_keys {
 	u8 standard_rss_key[ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE];
 	u8 extended_hash_key[ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE];
Signature · 1 line
2.13.6
#25 lore raw

Re: [PATCH 22/37] net/ice/base: add RSS key related macro and structures

ACK

-----Original Message-----
From: Zhang, Qi Z
Sent: Wednesday, February 27, 2019 9:57 PM
To: Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>
Cc: Stillwell Jr, Paul M <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>; Greenwalt, Paul <[email protected]>
Subject: [PATCH 22/37] net/ice/base: add RSS key related macro and structures

Add define for 52 byte RSS hash key size, and add struct ice_aqc_get_set_rss_keys comments regarding setting 40 bytes and 52 byte hash key.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +14 -0
index cb1e1ca1a..ed7dfae8c 100644
@@ -1593,7 +1593,20 @@ struct ice_aqc_get_set_rss_key {
 
 #define ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE	0x28
 #define ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE	0xC
+#define ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE \
+				(ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE + \
+				 ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE)
 
+/**
+ * struct ice_aqc_get_set_rss_keys - Get/Set RSS hash key command 
+buffer
+ * @standard_rss_key: 40 most significant bytes of hash key
+ * @extended_hash_key: 12 least significant bytes of hash key
+ *
+ * Set/Get 40 byte hash key using standard_rss_key field, and set
+ * extended_hash_key field to zero. Set/Get 52 byte hash key using
+ * standard_rss_key field for 40 most significant bytes and the
+ * extended_hash_key field for the 12 least significant bytes of hash key.
+ */
 struct ice_aqc_get_set_rss_keys {
 	u8 standard_rss_key[ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE];

u8 extended_hash_key[ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE];
--
2.13.6

author
#26 lore raw

PATCH 23/37 net/ice/base: do not write TCAM entries back

In reply to Qi Zhang

Profile TCAM entry removal is handled by the firmware when freeing the resource, so the driver does not need to write these default entries back with an update Package action.

This patch removes writing of the TCAM entry using Update Package command when removing it, since the entry has already been freed by firmware.

---
 drivers/net/ice/base/ice_flex_pipe.c | 41 +++++++++---------------------------
 drivers/net/ice/base/ice_flex_type.h |  2 --
 2 files changed, 10 insertions(+), 33 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +10 -31
index ff615f94f..900a19387 100644
@@ -3558,8 +3558,7 @@ ice_prof_bld_tcam(struct ice_hw *hw, enum ice_block blk,
 	struct ice_chs_chg *tmp;
 
 	LIST_FOR_EACH_ENTRY(tmp, chgs, ice_chs_chg, list_entry) {
-		if ((tmp->type == ICE_TCAM_ADD && tmp->add_tcam_idx) ||
-		    tmp->type == ICE_TCAM_REM) {
+		if (tmp->type == ICE_TCAM_ADD && tmp->add_tcam_idx) {
 			struct ice_prof_id_section *p;
 			u32 id;
 
@@ -3689,7 +3688,6 @@ ice_upd_prof_hw(struct ice_hw *hw, enum ice_block blk,
 				es++;
 			break;
 		case ICE_TCAM_ADD:
-		case ICE_TCAM_REM:
 			tcam++;
 			break;
 		case ICE_VSIG_ADD:
@@ -3962,46 +3960,27 @@ ice_rel_tcam_idx(struct ice_hw *hw, enum ice_block blk, u16 idx)
  * ice_rem_prof_id - remove one profile from a VSIG
  * @hw: pointer to the HW struct
  * @blk: hardware block
- * @vsig: VSIG to remove the profile from
  * @prof: pointer to profile structure to remove
- * @chg: pointer to list to record changes
  */
 static enum ice_status
-ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk, u16 vsig,
-		struct ice_vsig_prof *prof, struct LIST_HEAD_TYPE *chg)
+ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk,
+		struct ice_vsig_prof *prof)
 {
 	enum ice_status status;
-	struct ice_chs_chg *p;
 	u16 i;
 
 	for (i = 0; i < prof->tcam_count; i++) {
-		p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
-		if (!p)
-			goto err_ice_rem_prof_id;
-
-		p->type = ICE_TCAM_REM;
-		p->vsig = vsig;
-		p->prof_id = prof->tcam[i].prof_id;
-		p->tcam_idx = prof->tcam[i].tcam_idx;
-
-		p->ptg = prof->tcam[i].ptg;
 		prof->tcam[i].in_use = false;
-		p->orig_ent = hw->blk[blk].prof.t[p->tcam_idx];
-		status = ice_rel_tcam_idx(hw, blk, p->tcam_idx);
+		status = ice_rel_tcam_idx(hw, blk, prof->tcam[i].tcam_idx);
 		if (!status)
-			status = ice_prof_dec_ref(hw, blk, p->prof_id);
-
-		LIST_ADD(&p->list_entry, chg);
+			status = ice_prof_dec_ref(hw, blk,
+						  prof->tcam[i].prof_id);
 
 		if (status)
-			goto err_ice_rem_prof_id;
+			return ICE_ERR_HW_TABLE;
 	}
 
 	return ICE_SUCCESS;
-
-err_ice_rem_prof_id:
-	/* caller will clean up the change list */
-	return ICE_ERR_NO_MEMORY;
 }
 
 /**
@@ -4024,9 +4003,9 @@ ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
 	LIST_FOR_EACH_ENTRY_SAFE(d, t,
 				 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
 				 ice_vsig_prof, list) {
-		status = ice_rem_prof_id(hw, blk, vsig, d, chg);
+		status = ice_rem_prof_id(hw, blk, d);
 		if (status)
-			goto err_ice_rem_vsig;
+			return status;
 
 		LIST_DEL(&d->list);
 		ice_free(hw, d);
@@ -4090,7 +4069,7 @@ ice_rem_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 				/* this is the last profile, remove the VSIG */
 				return ice_rem_vsig(hw, blk, vsig, chg);
 
-			status = ice_rem_prof_id(hw, blk, vsig, p, chg);
+			status = ice_rem_prof_id(hw, blk, p);
 			if (!status) {
 				LIST_DEL(&p->list);
 				ice_free(hw, p);
drivers/net/ice/base/ice_flex_type.h +0 -2
index aed23a067..1bb865896 100644
@@ -676,7 +676,6 @@ enum ice_chg_type {
 	ICE_TCAM_NONE = 0,
 	ICE_PTG_ES_ADD,
 	ICE_TCAM_ADD,
-	ICE_TCAM_REM,
 	ICE_VSIG_ADD,
 	ICE_VSIG_REM,
 	ICE_VSI_MOVE,
@@ -697,7 +696,6 @@ struct ice_chs_chg {
 	u16 vsig;
 	u16 orig_vsig;
 	u16 tcam_idx;
-	struct ice_prof_tcam_entry orig_ent;
 };
 
 #define ICE_FLOW_PTYPE_MAX		ICE_XLT1_CNT
Signature · 1 line
2.13.6
author
#27 lore raw

PATCH 24/37 net/ice/base: remove local VSIG allocations

In reply to Qi Zhang

If allocating a VSI to a VSIG fails the local allocations made for VSIG profiles and change-lists will not be removed. Adding calls to free these entries on error in VSIG management calls.

---
 drivers/net/ice/base/ice_flex_pipe.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +15 -5
index 900a19387..887609204 100644
@@ -4523,8 +4523,10 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 		/* allocate the TCAM entry index */
 		status = ice_alloc_tcam_ent(hw, blk, &tcam_idx);
-		if (status)
+		if (status) {
+			ice_free(hw, p);
 			goto err_ice_add_prof_id_vsig;
+		}
 
 		t->tcam[i].ptg = ptg;
 		t->tcam[i].prof_id = map->prof_id;
@@ -4563,6 +4565,7 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 err_ice_add_prof_id_vsig:
 	/* let caller clean up the change list */
+	ice_free(hw, t);
 	return ICE_ERR_NO_MEMORY;
 }
 
@@ -4587,16 +4590,18 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 		return ICE_ERR_NO_MEMORY;
 
 	new_vsig = ice_vsig_alloc(hw, blk);
-	if (!new_vsig)
-		return ICE_ERR_HW_TABLE;
+	if (!new_vsig) {
+		status = ICE_ERR_HW_TABLE;
+		goto err_ice_create_prof_id_vsig;
+	}
 
 	status = ice_move_vsi(hw, blk, vsi, new_vsig, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	p->type = ICE_VSIG_ADD;
 	p->vsi = vsi;
@@ -4606,6 +4611,11 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 	LIST_ADD(&p->list_entry, chg);
 
 	return ICE_SUCCESS;
+
+err_ice_create_prof_id_vsig:
+	/* let caller clean up the change list */
+	ice_free(hw, p);
+	return status;
 }
 
 /**
Signature · 1 line
2.13.6
author
#28 lore raw

PATCH 25/37 net/ice/base: minor fix

In reply to Qi Zhang

1. Fix some problems with filling the HW tables.
2. Fix a logic error in ice_rem_prof_from_list.

---
 drivers/net/ice/base/ice_flex_pipe.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +15 -3
index 887609204..1dd121b28 100644
@@ -2935,9 +2935,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 
 	while (sect) {
 		switch (sid) {
+		case ICE_SID_XLT1_SW:
 		case ICE_SID_XLT1_FD:
 		case ICE_SID_XLT1_RSS:
 		case ICE_SID_XLT1_ACL:
+		case ICE_SID_XLT1_PE:
 			xlt1 = (struct ice_xlt1_section *)sect;
 			src = xlt1->value;
 			sect_len = LE16_TO_CPU(xlt1->count) *
@@ -2946,9 +2948,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].xlt1.count *
 				sizeof(*hw->blk[block_id].xlt1.t);
 			break;
+		case ICE_SID_XLT2_SW:
 		case ICE_SID_XLT2_FD:
 		case ICE_SID_XLT2_RSS:
 		case ICE_SID_XLT2_ACL:
+		case ICE_SID_XLT2_PE:
 			xlt2 = (struct ice_xlt2_section *)sect;
 			src = (u8 *)xlt2->value;
 			sect_len = LE16_TO_CPU(xlt2->count) *
@@ -2957,9 +2961,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].xlt2.count *
 				sizeof(*hw->blk[block_id].xlt2.t);
 			break;
+		case ICE_SID_PROFID_TCAM_SW:
 		case ICE_SID_PROFID_TCAM_FD:
 		case ICE_SID_PROFID_TCAM_RSS:
 		case ICE_SID_PROFID_TCAM_ACL:
+		case ICE_SID_PROFID_TCAM_PE:
 			pid = (struct ice_prof_id_section *)sect;
 			src = (u8 *)pid->entry;
 			sect_len = LE16_TO_CPU(pid->count) *
@@ -2968,9 +2974,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].prof.count *
 				sizeof(*hw->blk[block_id].prof.t);
 			break;
+		case ICE_SID_PROFID_REDIR_SW:
 		case ICE_SID_PROFID_REDIR_FD:
 		case ICE_SID_PROFID_REDIR_RSS:
 		case ICE_SID_PROFID_REDIR_ACL:
+		case ICE_SID_PROFID_REDIR_PE:
 			pr = (struct ice_prof_redir_section *)sect;
 			src = pr->redir_value;
 			sect_len = LE16_TO_CPU(pr->count) *
@@ -2979,15 +2987,19 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].prof_redir.count *
 				sizeof(*hw->blk[block_id].prof_redir.t);
 			break;
+		case ICE_SID_FLD_VEC_SW:
 		case ICE_SID_FLD_VEC_FD:
 		case ICE_SID_FLD_VEC_RSS:
 		case ICE_SID_FLD_VEC_ACL:
+		case ICE_SID_FLD_VEC_PE:
 			es = (struct ice_sw_fv_section *)sect;
 			src = (u8 *)es->fv;
 			sect_len = LE16_TO_CPU(es->count) *
-				sizeof(*hw->blk[block_id].prof_redir.t);
+				hw->blk[block_id].es.fvw *
+				sizeof(*hw->blk[block_id].es.t);
 			dst = (u8 *)hw->blk[block_id].es.t;
 			dst_len = hw->blk[block_id].es.count *
+				hw->blk[block_id].es.fvw *
 				sizeof(*hw->blk[block_id].es.t);
 			break;
 		default:
@@ -4964,8 +4976,8 @@ ice_rem_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl)
 				if (status)
 					goto err_ice_rem_prof_id_flow;
 
-			} else if (ice_find_dup_props_vsig(hw, blk, &copy,
-							   &vsig)) {
+			} else if (!ice_find_dup_props_vsig(hw, blk, &copy,
+							    &vsig)) {
 				/* found an exact match */
 				/* add or move VSI to the VSIG that matches */
 				/* Search for a VSIG with a matching profile
Signature · 1 line
2.13.6
author
#29 lore raw

PATCH 26/37 net/ice/base: update copyright time

In reply to Qi Zhang

Update copyright time to 2019.

---
 drivers/net/ice/base/ice_adminq_cmd.h    | 2 +-
 drivers/net/ice/base/ice_alloc.h         | 2 +-
 drivers/net/ice/base/ice_common.c        | 2 +-
 drivers/net/ice/base/ice_common.h        | 2 +-
 drivers/net/ice/base/ice_controlq.c      | 2 +-
 drivers/net/ice/base/ice_controlq.h      | 2 +-
 drivers/net/ice/base/ice_devids.h        | 2 +-
 drivers/net/ice/base/ice_flex_type.h     | 2 +-
 drivers/net/ice/base/ice_flow.h          | 2 +-
 drivers/net/ice/base/ice_hw_autogen.h    | 2 +-
 drivers/net/ice/base/ice_lan_tx_rx.h     | 2 +-
 drivers/net/ice/base/ice_nvm.c           | 2 +-
 drivers/net/ice/base/ice_protocol_type.h | 2 +-
 drivers/net/ice/base/ice_sbq_cmd.h       | 2 +-
 drivers/net/ice/base/ice_sched.c         | 2 +-
 drivers/net/ice/base/ice_sched.h         | 2 +-
 drivers/net/ice/base/ice_status.h        | 2 +-
 drivers/net/ice/base/ice_switch.c        | 2 +-
 drivers/net/ice/base/ice_switch.h        | 2 +-
 drivers/net/ice/base/ice_type.h          | 2 +-
 20 files changed, 20 insertions(+), 20 deletions(-)
drivers/net/ice/base/ice_adminq_cmd.h +1 -1
index ed7dfae8c..81a331b41 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_ADMINQ_CMD_H_
drivers/net/ice/base/ice_alloc.h +1 -1
index 78831045b..cf823a2c2 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_ALLOC_H_
drivers/net/ice/base/ice_common.c +1 -1
index 1c381b5e2..ae0e7fc5f 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_common.h"
drivers/net/ice/base/ice_common.h +1 -1
index 72560fbbf..cc7a77747 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_COMMON_H_
drivers/net/ice/base/ice_controlq.c +1 -1
index 1c0830cec..f3404023a 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_common.h"
drivers/net/ice/base/ice_controlq.h +1 -1
index db2db9389..182db6754 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_CONTROLQ_H_
drivers/net/ice/base/ice_devids.h +1 -1
index 87f17ab91..5f1ac0422 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_DEVIDS_H_
drivers/net/ice/base/ice_flex_type.h +1 -1
index 1bb865896..951c2051f 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_FLEX_TYPE_H_
drivers/net/ice/base/ice_flow.h +1 -1
index 3db10cd6f..bad925c8c 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_FLOW_H_
drivers/net/ice/base/ice_hw_autogen.h +1 -1
index 8c79891ad..e63e41133 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 /* Machine-generated file; do not edit */
drivers/net/ice/base/ice_lan_tx_rx.h +1 -1
index b1963b5eb..8c9902994 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_LAN_TX_RX_H_
drivers/net/ice/base/ice_nvm.c +1 -1
index 8d3d0b0ed..b770abfd0 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_common.h"
drivers/net/ice/base/ice_protocol_type.h +1 -1
index f96964d86..6b3bd6542 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_PROTOCOL_TYPE_H_
drivers/net/ice/base/ice_sbq_cmd.h +1 -1
index 6dff37871..70a019292 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_SBQ_CMD_H_
drivers/net/ice/base/ice_sched.c +1 -1
index 2dd9f6f6c..8773e62a9 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_sched.h"
drivers/net/ice/base/ice_sched.h +1 -1
index 09de765ff..92377a82e 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_SCHED_H_
drivers/net/ice/base/ice_status.h +1 -1
index 898bfa6d8..cd561b0a4 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_STATUS_H_
drivers/net/ice/base/ice_switch.c +1 -1
index e47c1d845..a1c29d606 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_switch.h"
drivers/net/ice/base/ice_switch.h +1 -1
index 3cc2c10e8..13525d8d0 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_SWITCH_H_
drivers/net/ice/base/ice_type.h +1 -1
index 25d64477f..90736faa1 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_TYPE_H_
Signature · 1 line
2.13.6
author
#30 lore raw

PATCH 27/37 net/ice/base: resolve static analysis reported issues

In reply to Qi Zhang

Resolve static analysis reported issue in
ice_get_itr_intrl_gran and ice_ptg_find_ptype.

---
 drivers/net/ice/base/ice_common.c    | 12 ++----------
 drivers/net/ice/base/ice_flex_pipe.c |  7 +------
 2 files changed, 3 insertions(+), 16 deletions(-)
drivers/net/ice/base/ice_common.c +2 -10
index ae0e7fc5f..2362dd774 100644
@@ -741,7 +741,7 @@ void ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf)
  * Determines the itr/intrl granularities based on the maximum aggregate
  * bandwidth according to the device's configuration during power-on.
  */
-static enum ice_status ice_get_itr_intrl_gran(struct ice_hw *hw)
+static void ice_get_itr_intrl_gran(struct ice_hw *hw)
 {
 	u8 max_agg_bw = (rd32(hw, GL_PWR_MODE_CTL) &
 			 GL_PWR_MODE_CTL_CAR_MAX_BW_M) >>
@@ -758,13 +758,7 @@ static enum ice_status ice_get_itr_intrl_gran(struct ice_hw *hw)
 		hw->itr_gran = ICE_ITR_GRAN_MAX_25;
 		hw->intrl_gran = ICE_INTRL_GRAN_MAX_25;
 		break;
-	default:
-		ice_debug(hw, ICE_DBG_INIT,
-			  "Failed to determine itr/intrl granularity\n");
-		return ICE_ERR_CFG;
 	}
-
-	return ICE_SUCCESS;
 }
 
 /**
@@ -795,9 +789,7 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 	if (status)
 		return status;
 
-	status = ice_get_itr_intrl_gran(hw);
-	if (status)
-		return status;
+	ice_get_itr_intrl_gran(hw);
 
 
 	status = ice_init_all_ctrlq(hw);
drivers/net/ice/base/ice_flex_pipe.c +1 -6
index 1dd121b28..525378079 100644
@@ -4288,17 +4288,12 @@ ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk,
 	p->tcam_count = map->ptype_count;
 
 	for (i = 0; i < map->ptype_count; i++) {
-		enum ice_status status;
 		u8 ptg;
 
 		p->tcam[i].prof_id = map->prof_id;
 		p->tcam[i].tcam_idx = ICE_INVALID_TCAM;
 
-		status = ice_ptg_find_ptype(hw, blk, map->ptype[i], &ptg);
-		if (status) {
-			ice_free(hw, p);
-			return status;
-		}
+		ice_ptg_find_ptype(hw, blk, map->ptype[i], &ptg);
 
 		p->tcam[i].ptg = ptg;
 	}
Signature · 1 line
2.13.6
#31 lore raw

Re: [PATCH 27/37] net/ice/base: resolve static analysis reported issues

Quoted 2 lines · Qi Zhang

Resolve static analysis reported issue in
ice_get_itr_intrl_gran and ice_ptg_find_ptype.

Same comment with previous patch, related to the commit log.

Commit log says "static analysis reported issues" are solved, what are they really? If we know them we can know your intention and say something about the code below, otherwise is there a way to figure out if something wrong below?

And "impact" part, "what is the impact of the change?" Will those issues create definite memory corruption? Or protection for possible issue. Knowing this helps maintainers and LTS maintainers to priorities the patch accordingly.

Also please use "fix" instead of "resolve", fix is kind of keyword we tend to use, and provide a fixes line for whatever fixed.

Quoted 4 lines
#32 lore raw

Re: [PATCH 27/37] net/ice/base: resolve static analysis reported issues

Quoted 12 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 1, 2019 6:37 PM
To: Zhang, Qi Z <[email protected]>; Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>
Cc: Stillwell Jr, Paul M <[email protected]>; [email protected]; Allan, Bruce W <[email protected]>
Subject: Re: [PATCH 27/37] net/ice/base: resolve static analysis reported issues

On 2/28/2019 5:56 AM, Qi Zhang wrote:

Quoted 8 lines
Quoted 2 lines

Resolve static analysis reported issue in ice_get_itr_intrl_gran and ice_ptg_find_ptype.

Same comment with previous patch, related to the commit log.

Commit log says "static analysis reported issues" are solved, what are they really? If we know them we can know your intention and say something about the code below, otherwise is there a way to figure out if something wrong below?

OK, I think we can add more explanation here.

Quoted 5 lines

And "impact" part, "what is the impact of the change?" Will those issues create definite memory corruption? Or protection for possible issue. Knowing this helps maintainers and LTS maintainers to priorities the patch accordingly.

The ice driver is claimed as an experimental release in 19.02, only basic function is enabled and the quality is not guaranteed, We assume user already know this and expected to meet some issue,
Also 19.02 is not LTS release, so maintainer no need to worry about fix back port.
so from my view, the "impact" part is not necessary to be highlighted for this patch but a nice to have, am I right?

Quoted 2 lines

Also please use "fix" instead of "resolve", fix is kind of keyword we tend to use, and provide a fixes line for whatever fixed.

OK, will add fix line for this.

Thanks
Qi

Quoted 6 lines
Quoted 5 lines
author
#33 lore raw

PATCH 28/37 net/ice/base: return config error without queue to disable

In reply to Qi Zhang

If there is no queue to disable, return appropriate configuration error earlier without acquiring the lock.

---
 drivers/net/ice/base/ice_common.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ice/base/ice_common.c +10 -7
index 2362dd774..c35a2f91d 100644
@@ -3654,14 +3654,17 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
 	if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
 		return ICE_ERR_CFG;
 
-	/* if queue is disabled already yet the disable queue command has to be
-	 * sent to complete the VF reset, then call ice_aq_dis_lan_txq without
-	 * any queue information
-	 */
 
-	if (!num_queues && rst_src)
-		return ice_aq_dis_lan_txq(pi->hw, 0, NULL, 0, rst_src, vmvf_num,
-					  NULL);
+	if (!num_queues) {
+		/* if queue is disabled already yet the disable queue command
+		 * has to be sent to complete the VF reset, then call
+		 * ice_aq_dis_lan_txq without any queue information
+		 */
+		if (rst_src)
+			return ice_aq_dis_lan_txq(pi->hw, 0, NULL, 0, rst_src,
+						  vmvf_num, NULL);
+		return ICE_ERR_CFG;
+	}
 
 	ice_acquire_lock(&pi->sched_lock);
 
Signature · 1 line
2.13.6
author
#34 lore raw

PATCH 29/37 net/ice/base: add function to check FW recovery mode

In reply to Qi Zhang

Code added to check the FW recovery mode. This function will be used by the drivers during init to check whether the FW is in recovery mode or not. If FW is in recovery mode then the drivers need to run in a recovery mode where it can allow only limited operations. Link should be down, allow only certain AQ commands etc.

---
 drivers/net/ice/base/ice_common.c | 15 +++++++++++++++
 drivers/net/ice/base/ice_common.h |  8 ++++++++
 2 files changed, 23 insertions(+)
drivers/net/ice/base/ice_common.c +15 -0
index c35a2f91d..2ebf95eed 100644
@@ -3915,3 +3915,18 @@ ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
 		ice_debug(hw, ICE_DBG_SCHED, "query element failed\n");
 	return status;
 }
+
+/**
+ * ice_is_fw_in_rec_mode
+ * @hw: pointer to the HW struct
+ *
+ * This function returns true if fw is in recovery mode
+ */
+bool ice_is_fw_in_rec_mode(struct ice_hw *hw)
+{
+	u32 reg;
+
+	/* check the current FW mode */
+	reg = rd32(hw, GL_MNG_FWSM);
+	return (reg & GL_MNG_FWSM_FW_MODES_M) > ICE_FW_MODE_DBG;
+}
drivers/net/ice/base/ice_common.h +8 -0
index cc7a77747..9665f3204 100644
@@ -10,6 +10,13 @@
 #include "ice_flex_pipe.h"
 #include "ice_switch.h"
 
+enum ice_fw_modes {
+	ICE_FW_MODE_NORMAL,
+	ICE_FW_MODE_DBG,
+	ICE_FW_MODE_REC,
+	ICE_FW_MODE_DBG_REC
+};
+
 enum ice_status ice_nvm_validate_checksum(struct ice_hw *hw);
 
 void
@@ -188,4 +195,5 @@ ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
 enum ice_status
 ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
 		     struct ice_aqc_get_elem *buf);
+bool ice_is_fw_in_rec_mode(struct ice_hw *hw);
 #endif /* _ICE_COMMON_H_ */
Signature · 1 line
2.13.6
author
#35 lore raw

PATCH 30/37 net/ice/base: change profile id reference counting

In reply to Qi Zhang

Improved the profile reference counting, by moving it from being based on how many TCAM entries using the profile to how many profile map entries are using the profile.

---
 drivers/net/ice/base/ice_flex_pipe.c | 70 ++++++++++++++++++++----------------
 drivers/net/ice/base/ice_flex_type.h |  1 +
 2 files changed, 41 insertions(+), 30 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +40 -30
index 525378079..99108d81c 100644
@@ -2816,6 +2816,30 @@ ice_prof_inc_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
 }
 
 /**
+ * ice_write_es - write an extraction sequence to hardware
+ * @hw: pointer to the HW struct
+ * @blk: the block in which to write the extraction sequence
+ * @prof_id: the profile ID to write
+ * @fv: pointer to the extraction sequence to write - NULL to clear extraction
+ */
+static void
+ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id,
+	     struct ice_fv_word *fv)
+{
+	u16 off;
+
+	off = prof_id * hw->blk[blk].es.fvw;
+	if (!fv) {
+		ice_memset(&hw->blk[blk].es.t[off], 0, hw->blk[blk].es.fvw *
+			   sizeof(*fv), ICE_NONDMA_MEM);
+		hw->blk[blk].es.written[prof_id] = false;
+	} else {
+		ice_memcpy(&hw->blk[blk].es.t[off], fv, hw->blk[blk].es.fvw *
+			   sizeof(*fv), ICE_NONDMA_TO_NONDMA);
+	}
+}
+
+/**
  * ice_prof_dec_ref - decrement reference count for profile
  * @hw: pointer to the HW struct
  * @blk: the block from which to free the profile ID
@@ -2828,31 +2852,15 @@ ice_prof_dec_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
 		return ICE_ERR_PARAM;
 
 	if (hw->blk[blk].es.ref_count[prof_id] > 0) {
-		if (!--hw->blk[blk].es.ref_count[prof_id])
+		if (!--hw->blk[blk].es.ref_count[prof_id]) {
+			ice_write_es(hw, blk, prof_id, NULL);
 			return ice_free_prof_id(hw, blk, prof_id);
+		}
 	}
 
 	return ICE_SUCCESS;
 }
 
-/**
- * ice_write_es - write an extraction sequence to hardware
- * @hw: pointer to the HW struct
- * @blk: the block in which to write the extraction sequence
- * @prof_id: the profile ID to write
- * @fv: pointer to the extraction sequence to write
- */
-static void
-ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id,
-	     struct ice_fv_word *fv)
-{
-	u16 off;
-
-	off = prof_id * hw->blk[blk].es.fvw;
-	ice_memcpy(&hw->blk[blk].es.t[off], fv, hw->blk[blk].es.fvw * 2,
-		   ICE_NONDMA_TO_NONDMA);
-}
-
 /* Block / table section IDs */
 static const u32 ice_blk_sids[ICE_BLK_COUNT][ICE_SID_OFF_COUNT] = {
 	/* SWITCH */
@@ -3140,6 +3148,7 @@ void ice_free_hw_tbls(struct ice_hw *hw)
 
 		ice_free(hw, hw->blk[i].es.resource_used_hack);
 		ice_free(hw, hw->blk[i].prof.resource_used_hack);
+		ice_free(hw, hw->blk[i].es.written);
 	}
 
 	ice_memset(hw->blk, 0, sizeof(hw->blk), ICE_NONDMA_MEM);
@@ -3309,6 +3318,9 @@ enum ice_status ice_init_hw_tbls(struct ice_hw *hw)
 		es->ref_count = (u16 *)
 			ice_calloc(hw, es->count, sizeof(*es->ref_count));
 
+		es->written = (u8 *)
+			ice_calloc(hw, es->count, sizeof(*es->written));
+
 		if (!es->ref_count)
 			goto err;
 
@@ -3805,6 +3817,8 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[],
 		ice_write_es(hw, blk, prof_id, es);
 	}
 
+	ice_prof_inc_ref(hw, blk, prof_id);
+
 	/* add profile info */
 
 	prof = (struct ice_prof_map *)ice_malloc(hw, sizeof(*prof));
@@ -3984,10 +3998,6 @@ ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk,
 	for (i = 0; i < prof->tcam_count; i++) {
 		prof->tcam[i].in_use = false;
 		status = ice_rel_tcam_idx(hw, blk, prof->tcam[i].tcam_idx);
-		if (!status)
-			status = ice_prof_dec_ref(hw, blk,
-						  prof->tcam[i].prof_id);
-
 		if (status)
 			return ICE_ERR_HW_TABLE;
 	}
@@ -4159,6 +4169,9 @@ enum ice_status ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id)
 	status = ice_rem_flow_all(hw, blk, pmap->profile_cookie);
 	if (status)
 		return status;
+	/* dereference profile, and possibly remove */
+	ice_prof_dec_ref(hw, blk, pmap->prof_id);
+
 	LIST_DEL(&pmap->list);
 	ice_free(hw, pmap);
 
@@ -4194,7 +4207,7 @@ ice_get_prof_ptgs(struct ice_hw *hw, enum ice_block blk, u64 hdl,
 		if (status)
 			goto err_ice_get_prof_ptgs;
 
-		if (add || !hw->blk[blk].es.ref_count[map->prof_id]) {
+		if (add || !hw->blk[blk].es.written[map->prof_id]) {
 			/* add PTG to change list */
 			p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
 			if (!p)
@@ -4205,9 +4218,11 @@ ice_get_prof_ptgs(struct ice_hw *hw, enum ice_block blk, u64 hdl,
 			p->ptg = ptg;
 			p->add_ptg = add;
 
-			p->add_prof = !hw->blk[blk].es.ref_count[map->prof_id];
+			p->add_prof = !hw->blk[blk].es.written[map->prof_id];
 			p->prof_id = map->prof_id;
 
+			hw->blk[blk].es.written[map->prof_id] = true;
+
 			LIST_ADD(&p->list_entry, chg);
 		}
 	}
@@ -4555,11 +4570,6 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 		if (status)
 			goto err_ice_add_prof_id_vsig;
 
-		/* this increments the reference count of how many TCAM entries
-		 * are using this HW profile ID
-		 */
-		status = ice_prof_inc_ref(hw, blk, t->tcam[i].prof_id);
-
 		/* log change */
 		LIST_ADD(&p->list_entry, chg);
 	}
drivers/net/ice/base/ice_flex_type.h +1 -0
index 951c2051f..365f33390 100644
@@ -497,6 +497,7 @@ struct ice_es {
 	u16 count;
 	u16 fvw;
 	u16 *ref_count;
+	u8 *written;
 	u8 reverse; /* set to true to reverse FV order */
 	struct LIST_HEAD_TYPE prof_map;
 	struct ice_fv_word *t;
Signature · 1 line
2.13.6
author
#36 lore raw

PATCH 31/37 net/ice/base: add DCB support

In reply to Qi Zhang

Add module to support DCB related features.

---
 drivers/net/ice/Makefile              |    1 +
 drivers/net/ice/base/ice_adminq_cmd.h |  243 ++++++
 drivers/net/ice/base/ice_common.c     |   12 +
 drivers/net/ice/base/ice_dcb.c        | 1393 +++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_dcb.h        |  223 ++++++
 drivers/net/ice/base/ice_status.h     |    1 +
 drivers/net/ice/base/ice_type.h       |   14 +-
 drivers/net/ice/base/meson.build      |    1 +
 8 files changed, 1884 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_dcb.c
 create mode 100644 drivers/net/ice/base/ice_dcb.h
drivers/net/ice/Makefile +1 -0
index 61846cae2..89d21334e 100644
@@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_switch.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_nvm.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flex_pipe.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcb.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_rxtx.c
drivers/net/ice/base/ice_adminq_cmd.h +243 -0

301 lines not on this page · raw message

drivers/net/ice/base/ice_common.c +12 -0
index 2ebf95eed..202592710 100644
@@ -1930,6 +1930,18 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
 					  number);
 			}
 			break;
+		case ICE_AQC_CAPS_DCB:
+			caps->dcb = (number == 1);
+			caps->active_tc_bitmap = logical_id;
+			caps->maxtc = phys_id;
+			ice_debug(hw, ICE_DBG_INIT,
+				  "HW caps: DCB = %d\n", caps->dcb);
+			ice_debug(hw, ICE_DBG_INIT,
+				  "HW caps: Active TC bitmap = %d\n",
+				  caps->active_tc_bitmap);
+			ice_debug(hw, ICE_DBG_INIT,
+				  "HW caps: TC Max = %d\n", caps->maxtc);
+			break;
 		case ICE_AQC_CAPS_RSS:
 			caps->rss_table_size = number;
 			caps->rss_table_entry_width = logical_id;
drivers/net/ice/base/ice_dcb.c new file +1393 -0

1,393 lines not on this page · raw message

drivers/net/ice/base/ice_dcb.h new file +223 -0

223 lines not on this page · raw message

drivers/net/ice/base/ice_status.h +1 -0
index cd561b0a4..ac120fa30 100644
@@ -13,6 +13,7 @@ enum ice_status {
 	ICE_ERR_PARAM				= -1,
 	ICE_ERR_NOT_IMPL			= -2,
 	ICE_ERR_NOT_READY			= -3,
+	ICE_ERR_NOT_SUPPORTED			= -4,
 	ICE_ERR_BAD_PTR				= -5,
 	ICE_ERR_INVAL_SIZE			= -6,
 	ICE_ERR_DEVICE_NOT_SUPPORTED		= -8,
drivers/net/ice/base/ice_type.h +10 -4
index 90736faa1..6a08b3d28 100644
@@ -240,6 +240,9 @@ struct ice_hw_common_caps {
 
 	u32 os2bmc;
 	u32 valid_functions;
+	/* DCB capabilities */
+	u32 active_tc_bitmap;
+	u32 maxtc;
 
 	/* RSS related capabilities */
 	u32 rss_table_size;		/* 512 for PFs and 64 for VFs */
@@ -276,6 +279,7 @@ struct ice_hw_common_caps {
 	u8 evb_802_1_qbg;		/* Edge Virtual Bridging */
 	u8 evb_802_1_qbh;		/* Bridge Port Extension */
 
+	u8 dcb;
 	u8 iscsi;
 	u8 mgmt_cem;
 
@@ -527,7 +531,6 @@ struct ice_sched_vsi_info {
 	struct ice_bw_type_info bw_t_info[ICE_MAX_TRAFFIC_CLASS];
 };
 
-#if !defined(NO_DCB_SUPPORT) || defined(ADQ_SUPPORT)
 /* CEE or IEEE 802.1Qaz ETS Configuration data */
 struct ice_dcb_ets_cfg {
 	u8 willing;
@@ -580,7 +583,6 @@ struct ice_dcbx_cfg {
 	u8 app_mode;
 #define ICE_DCBX_APPS_NON_WILLING	0x1
 };
-#endif /* !NO_DCB_SUPPORT || ADQ_SUPPORT */
 
 struct ice_port_info {
 	struct ice_sched_node *root;	/* Root Node per Port */
@@ -601,9 +603,13 @@ struct ice_port_info {
 	struct ice_lock sched_lock;	/* protect access to TXSched tree */
 	/* List contain profile ID(s) and other params per layer */
 	struct LIST_HEAD_TYPE rl_prof_list[ICE_AQC_TOPO_MAX_LEVEL_NUM];
-#if !defined(NO_DCB_SUPPORT) || defined(ADQ_SUPPORT)
 	struct ice_dcbx_cfg local_dcbx_cfg;	/* Oper/Local Cfg */
-#endif /* !NO_DCB_SUPPORT || ADQ_SUPPORT */
+	/* DCBX info */
+	struct ice_dcbx_cfg remote_dcbx_cfg;	/* Peer Cfg */
+	struct ice_dcbx_cfg desired_dcbx_cfg;	/* CEE Desired Cfg */
+	/* LLDP/DCBX Status */
+	u8 dcbx_status;
+	u8 is_sw_lldp;
 	u8 lport;
 #define ICE_LPORT_MASK		0xff
 	u8 is_vf;
drivers/net/ice/base/meson.build +1 -0
index d7f8536bc..755d2497b 100644
@@ -9,6 +9,7 @@ sources = [
 	'ice_nvm.c',
 	'ice_flex_pipe.c',
 	'ice_flow.c',
+	'ice_dcb.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
Signature · 1 line
2.13.6
author
#37 lore raw

PATCH 32/37 net/ice/base: add FDIR support

In reply to Qi Zhang

Add flow director related support base code.

---
 drivers/net/ice/Makefile              |   1 +
 drivers/net/ice/base/ice_adminq_cmd.h |  13 +
 drivers/net/ice/base/ice_common.c     |  36 ++
 drivers/net/ice/base/ice_common.h     |   1 +
 drivers/net/ice/base/ice_fdir.c       | 742 ++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_fdir.h       | 202 +++++++++
 drivers/net/ice/base/ice_flex_pipe.c  | 232 +++++++++++
 drivers/net/ice/base/ice_type.h       |  55 +++
 drivers/net/ice/base/meson.build      |   1 +
 9 files changed, 1283 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_fdir.c
 create mode 100644 drivers/net/ice/base/ice_fdir.h
drivers/net/ice/Makefile +1 -0
index 89d21334e..a3aabccf1 100644
@@ -52,6 +52,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_nvm.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flex_pipe.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcb.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_fdir.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_rxtx.c
drivers/net/ice/base/ice_adminq_cmd.h +13 -0
index 4c5cf5419..d2ab9eeff 100644
@@ -105,6 +105,7 @@ struct ice_aqc_list_caps_elem {
 #define ICE_AQC_CAPS_RXQS				0x0041
 #define ICE_AQC_CAPS_TXQS				0x0042
 #define ICE_AQC_CAPS_MSIX				0x0043
+#define ICE_AQC_CAPS_FD					0x0045
 #define ICE_AQC_CAPS_MAX_MTU				0x0047
 
 	u8 major_ver;
@@ -1861,6 +1862,16 @@ struct ice_aqc_get_set_rss_lut {
 };
 
 
+/* Clear FD Table Command (direct, 0x0B06) */
+struct ice_aqc_clear_fd_table {
+	u8 clear_type;
+#define CL_FD_VM_VF_TYPE_VSI_IDX	1
+#define CL_FD_VM_VF_TYPE_PF_IDX		2
+	u8 rsvd;
+	__le16 vsi_index;
+	u8 reserved[12];
+};
+
 
 
 
@@ -2210,6 +2221,7 @@ struct ice_aq_desc {
 		struct ice_aqc_lldp_stop_start_specific_agent lldp_agent_ctrl;
 		struct ice_aqc_get_set_rss_lut get_set_rss_lut;
 		struct ice_aqc_get_set_rss_key get_set_rss_key;
+		struct ice_aqc_clear_fd_table clear_fd_table;
 		struct ice_aqc_add_txqs add_txqs;
 		struct ice_aqc_dis_txqs dis_txqs;
 		struct ice_aqc_txqs_cleanup txqs_cleanup;
@@ -2415,6 +2427,7 @@ enum ice_adminq_opc {
 	ice_aqc_opc_set_rss_lut				= 0x0B03,
 	ice_aqc_opc_get_rss_key				= 0x0B04,
 	ice_aqc_opc_get_rss_lut				= 0x0B05,
+	ice_aqc_opc_clear_fd_table			= 0x0B06,
 
 	/* Tx queue handling commands/events */
 	ice_aqc_opc_add_txqs				= 0x0C30,
drivers/net/ice/base/ice_common.c +36 -0
index 202592710..425f76e8d 100644
@@ -805,6 +805,9 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 	if (status)
 		goto err_unroll_cqinit;
 
+	/* Set bit to enable Flow Director filters */
+	wr32(hw, PFQF_FD_ENA, PFQF_FD_ENA_FD_ENA_M);
+	INIT_LIST_HEAD(&hw->fdir_list_head);
 
 	ice_clear_pxe_mode(hw);
 
@@ -901,6 +904,10 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 	ice_init_flex_flds(hw, ICE_RXDID_FLEX_NIC);
 	ice_init_flex_flds(hw, ICE_RXDID_FLEX_NIC_2);
 
+	/* Obtain counter base index which would be used by flow director */
+	status = ice_alloc_fd_res_cntr(hw, &hw->fd_ctr_base);
+	if (status)
+		goto err_unroll_fltr_mgmt_struct;
 
 	return ICE_SUCCESS;
 
@@ -926,6 +933,7 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
  */
 void ice_deinit_hw(struct ice_hw *hw)
 {
+	ice_free_fd_res_cntr(hw, hw->fd_ctr_base);
 	ice_cleanup_fltr_mgmt_struct(hw);
 
 	ice_sched_cleanup_all(hw);
@@ -1980,6 +1988,34 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
 				  "HW caps: MSIX first vector index = %d\n",
 				  caps->msix_vector_first_id);
 			break;
+		case ICE_AQC_CAPS_FD:
+		{
+			u32 reg_val, val;
+
+			if (dev_p) {
+				dev_p->num_flow_director_fltr = number;
+				ice_debug(hw, ICE_DBG_INIT,
+					  "HW caps: Dev.fd_fltr =%d\n",
+					  dev_p->num_flow_director_fltr);
+			}
+			if (func_p) {
+				reg_val = rd32(hw, GLQF_FD_SIZE);
+				val = (reg_val & GLQF_FD_SIZE_FD_GSIZE_M) >>
+				      GLQF_FD_SIZE_FD_GSIZE_S;
+				func_p->fd_fltr_guar =
+					ice_get_num_per_func(hw, val);
+				val = (reg_val & GLQF_FD_SIZE_FD_BSIZE_M) >>
+				      GLQF_FD_SIZE_FD_BSIZE_S;
+				func_p->fd_fltr_best_effort = val;
+				ice_debug(hw, ICE_DBG_INIT,
+					  "HW:func.fd_fltr guar= %d\n",
+					  func_p->fd_fltr_guar);
+				ice_debug(hw, ICE_DBG_INIT,
+					  "HW:func.fd_fltr best effort=%d\n",
+					  func_p->fd_fltr_best_effort);
+			}
+			break;
+		}
 		case ICE_AQC_CAPS_MAX_MTU:
 			caps->max_mtu = number;
 			if (dev_p)
drivers/net/ice/base/ice_common.h +1 -0
index 9665f3204..4dc43dcfe 100644
@@ -9,6 +9,7 @@
 
 #include "ice_flex_pipe.h"
 #include "ice_switch.h"
+#include "ice_fdir.h"
 
 enum ice_fw_modes {
 	ICE_FW_MODE_NORMAL,
drivers/net/ice/base/ice_fdir.c new file +742 -0

742 lines not on this page · raw message

drivers/net/ice/base/ice_fdir.h new file +202 -0

202 lines not on this page · raw message

drivers/net/ice/base/ice_flex_pipe.c +232 -0

256 lines not on this page · raw message

drivers/net/ice/base/ice_type.h +55 -0

103 lines not on this page · raw message

drivers/net/ice/base/meson.build +1 -0
index 755d2497b..624202567 100644
@@ -10,6 +10,7 @@ sources = [
 	'ice_flex_pipe.c',
 	'ice_flow.c',
 	'ice_dcb.c',
+	'ice_fdir.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
Signature · 1 line
2.13.6
author
#38 lore raw

PATCH 33/37 net/ice/base: change profile priority for RSS reply

In reply to Qi Zhang

1. Add call to replay RSS configurations
2. Add RSS configurations to end of list and not the head to avoid inversion on replay.

---
 drivers/net/ice/base/ice_common.c |  5 ++++-
 drivers/net/ice/base/ice_flow.c   |  3 ++-
 drivers/net/ice/base/ice_osdep.h  | 16 ++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/ice/base/ice_common.c +4 -1
index 425f76e8d..74f925c03 100644
@@ -3854,7 +3854,10 @@ enum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle)
 		if (status)
 			return status;
 	}
-
+	/* Replay per VSI all RSS configurations */
+	status = ice_replay_rss_cfg(hw, vsi_handle);
+	if (status)
+		return status;
 	/* Replay per VSI all filters */
 	status = ice_replay_vsi_all_fltr(hw, vsi_handle);
 	if (!status)
drivers/net/ice/base/ice_flow.c +2 -1
index 03a324d49..428002c28 100644
@@ -1672,7 +1672,8 @@ ice_add_rss_vsi_ctx(struct ice_hw *hw, u16 vsi_handle,
 
 	rss_cfg->hashed_flds = prof->segs[prof->segs_cnt - 1].match;
 	rss_cfg->packet_hdr = prof->segs[prof->segs_cnt - 1].hdrs;
-	LIST_ADD(&rss_cfg->l_entry, &hw->vsi_ctx[vsi_handle]->rss_list_head);
+	LIST_ADD_TAIL(&rss_cfg->l_entry,
+		      &hw->vsi_ctx[vsi_handle]->rss_list_head);
 
 	return ICE_SUCCESS;
 }
drivers/net/ice/base/ice_osdep.h +16 -0
index 252c8f4e7..560e36c1b 100644
@@ -462,6 +462,22 @@ LIST_HEAD(ice_list_head, ice_list_entry);
 #define LIST_ADD(entry, list_head)    LIST_INSERT_HEAD(list_head, entry, next)
 #define LIST_ADD_AFTER(entry, list_entry) \
 	LIST_INSERT_AFTER(list_entry, entry, next)
+
+static inline void list_add_tail(struct ice_list_entry *entry,
+				 struct ice_list_head *head)
+{
+	struct ice_list_entry *tail = head->lh_first;
+
+	if (tail == NULL) {
+		LIST_INSERT_HEAD(head, entry, next);
+		return;
+	}
+	while (tail->next.le_next != NULL)
+		tail = tail->next.le_next;
+	LIST_INSERT_AFTER(tail, entry, next);
+}
+
+#define LIST_ADD_TAIL(entry, head) list_add_tail(entry, head)
 #define LIST_FOR_EACH_ENTRY(pos, head, type, member)			       \
 	for ((pos) = (head)->lh_first ?					       \
 		     container_of((head)->lh_first, struct type, member) :     \
Signature · 1 line
2.13.6
author
#39 lore raw

PATCH 34/37 net/ice/base: remove duplicate resource allocations

In reply to Qi Zhang

This patch ensure that TCAM allocations made by a newly added VSIG that has the same characteristic list of an existing VSIG are removed.

---
 drivers/net/ice/base/ice_flex_pipe.c | 85 +++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 44 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +41 -44
index 37bb4cbb5..c9d8730d2 100644
@@ -2302,21 +2302,23 @@ ice_vsig_free(struct ice_hw *hw, enum ice_block blk, u16 vsig)
 	hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false;
 
 	vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
-	if (!vsi_cur)
-		return ICE_ERR_CFG;
-
-	/* remove all vsis associated with this VSIG XLT2 entry */
-	do {
-		struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
-
-		vsi_cur->vsig = ICE_DEFAULT_VSIG;
-		vsi_cur->changed = 1;
-		vsi_cur->next_vsi = NULL;
-		vsi_cur = tmp;
-	} while (vsi_cur);
-
-	/* NULL terminate head of vsi list */
-	hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL;
+	/* If the VSIG has at least 1 VSI then iterate through the
+	 * list and remove the VSIs before deleting the group.
+	 */
+	if (vsi_cur) {
+		/* remove all vsis associated with this VSIG XLT2 entry */
+		do {
+			struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
+
+			vsi_cur->vsig = ICE_DEFAULT_VSIG;
+			vsi_cur->changed = 1;
+			vsi_cur->next_vsi = NULL;
+			vsi_cur = tmp;
+		} while (vsi_cur);
+
+		/* NULL terminate head of VSI list */
+		hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL;
+	}
 
 	/* free characteristic list */
 	LIST_FOR_EACH_ENTRY_SAFE(del, dtmp,
@@ -4267,36 +4269,32 @@ ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
 
 	/* Move all VSIS associated with this VSIG to the default VSIG */
 	vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
-	if (!vsi_cur)
-		return ICE_ERR_CFG;
-
-	do {
-		struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
-		struct ice_chs_chg *p;
-
-		p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
-		if (!p)
-			goto err_ice_rem_vsig;
+	/* If the VSIG has at least 1 VSI then iterate through the list
+	 * and remove the VSIs before deleting the group.
+	 */
+	if (vsi_cur) {
+		do {
+			struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
+			struct ice_chs_chg *p;
 
-		p->type = ICE_VSIG_REM;
-		p->orig_vsig = vsig;
-		p->vsig = ICE_DEFAULT_VSIG;
-		p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis;
+			p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
+			if (!p)
+				return ICE_ERR_NO_MEMORY;
 
-		LIST_ADD(&p->list_entry, chg);
+			p->type = ICE_VSIG_REM;
+			p->orig_vsig = vsig;
+			p->vsig = ICE_DEFAULT_VSIG;
+			p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis;
 
-		status = ice_vsig_free(hw, blk, vsig);
-		if (status)
-			return status;
+			LIST_ADD(&p->list_entry, chg);
 
-		vsi_cur = tmp;
-	} while (vsi_cur);
+			vsi_cur = tmp;
+		} while (vsi_cur);
+	}
 
-	return ICE_SUCCESS;
+	status = ice_vsig_free(hw, blk, vsig);
 
-err_ice_rem_vsig:
-	/* the caller will free up the change list */
-	return ICE_ERR_NO_MEMORY;
+	return status;
 }
 
 /**
@@ -4493,7 +4491,7 @@ ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
 
 		ice_memcpy(p, ent1, sizeof(*p), ICE_NONDMA_TO_NONDMA);
 
-		LIST_ADD(&p->list, lst);
+		LIST_ADD_TAIL(&p->list, lst);
 	}
 
 	return ICE_SUCCESS;
@@ -5000,14 +4998,13 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl)
 		/* search for an existing VSIG with an exact charc match */
 		status = ice_find_dup_props_vsig(hw, blk, &union_lst, &vsig);
 		if (!status) {
-			/* found an exact match */
-			/* move vsi to the VSIG that matches */
+			/* move VSI to the VSIG that matches */
 			status = ice_move_vsi(hw, blk, vsi, vsig, &chg);
 			if (status)
 				goto err_ice_add_prof_id_flow;
 
-			/* remove original VSIG if we just moved the only VSI
-			 * from it
+			/* VSI has been moved out of or_vsig. If the or_vsig had
+			 * only that VSI it is now empty and can be removed.
 			 */
 			if (only_vsi) {
 				status = ice_rem_vsig(hw, blk, or_vsig, &chg);
Signature · 1 line
2.13.6
author
#40 lore raw

PATCH 35/37 net/ice/base: minor fix

In reply to Qi Zhang

1. clean flow entry's action structure after remove it.
2. initialized priority when add a new flow entry
3. remove RSS configuration before deleting the flow profile.

---
 drivers/net/ice/base/ice_flex_pipe.c |  2 +-
 drivers/net/ice/base/ice_flow.c      | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +1 -1
index c9d8730d2..e4d0b8c0f 100644
@@ -2467,7 +2467,7 @@ ice_find_prof_id(struct ice_hw *hw, enum ice_block blk,
 	for (i = 0; i < es->count; i++) {
 		off = i * es->fvw;
 
-		if (memcmp(&es->t[off], fv, es->fvw * 2))
+		if (memcmp(&es->t[off], fv, es->fvw * sizeof(*fv)))
 			continue;
 
 		*prof_id = i;
drivers/net/ice/base/ice_flow.c +10 -3
index 428002c28..98727cfeb 100644
@@ -910,8 +910,11 @@ ice_flow_rem_entry_sync(struct ice_hw *hw, struct ice_flow_entry *entry)
 	if (entry->entry)
 		ice_free(hw, entry->entry);
 
-	if (entry->acts)
+	if (entry->acts) {
 		ice_free(hw, entry->acts);
+		entry->acts = NULL;
+		entry->acts_cnt = 0;
+	}
 
 	ice_free(hw, entry);
 
@@ -1306,6 +1309,7 @@ ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
 	e->id = entry_id;
 	e->vsi_handle = vsi_handle;
 	e->prof = prof;
+	e->priority = prio;
 
 	switch (blk) {
 	case ICE_BLK_RSS:
@@ -1852,11 +1856,14 @@ ice_rem_rss_cfg_sync(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
 	if (status)
 		goto out;
 
+	/* Remove RSS configuration from VSI context before deleting
+	 * the flow profile.
+	 */
+	ice_rem_rss_cfg_vsi_ctx(hw, vsi_handle, prof);
+
 	if (!ice_is_any_bit_set(prof->vsis, ICE_MAX_VSI))
 		status = ice_flow_rem_prof_sync(hw, blk, prof);
 
-	ice_rem_rss_cfg_vsi_ctx(hw, vsi_handle, prof);
-
 out:
 	ice_free(hw, segs);
 	return status;
Signature · 1 line
2.13.6
author
#41 lore raw

PATCH 36/37 net/ice/base: increase prototol offset size

In reply to Qi Zhang

Increase field vector's protocol offset size from 8 bit to 16 bit.

---
 drivers/net/ice/base/ice_flex_type.h     | 8 +++++++-
 drivers/net/ice/base/ice_flow.c          | 7 +++++--
 drivers/net/ice/base/ice_flow.h          | 2 +-
 drivers/net/ice/base/ice_protocol_type.h | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_flex_type.h +7 -1
index 365f33390..f259e1371 100644
@@ -5,12 +5,18 @@
 #ifndef _ICE_FLEX_TYPE_H_
 #define _ICE_FLEX_TYPE_H_
 
+#define ICE_FV_OFFSET_INVAL    0x1FF
+
+#pragma pack(1)
 /* Extraction Sequence (Field Vector) Table */
 struct ice_fv_word {
 	u8 prot_id;
-	u8 off;		/* Offset within the protocol header */
+	u16 off;		/* Offset within the protocol header */
+	u8 resvrd;
 };
 
+#pragma pack()
+
 #define ICE_MAX_FV_WORDS 48
 struct ice_fv {
 	struct ice_fv_word ew[ICE_MAX_FV_WORDS];
drivers/net/ice/base/ice_flow.c +5 -2
index 98727cfeb..be819e0e9 100644
@@ -516,7 +516,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
 	struct ice_flow_fld_info *flds;
 	u16 cnt, ese_bits, i;
 	s16 adj = 0;
-	u8 off;
+	u16 off;
 
 	flds = params->prof->segs[seg].fields;
 
@@ -956,7 +956,10 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk,
 		return ICE_ERR_NO_MEMORY;
 
 	/* initialize extraction sequence to all invalid (0xff) */
-	ice_memset(params.es, 0xff, sizeof(params.es), ICE_NONDMA_MEM);
+	for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+		params.es[i].prot_id = ICE_PROT_INVALID;
+		params.es[i].off = ICE_FV_OFFSET_INVAL;
+	}
 
 	params.blk = blk;
 	params.prof->id = prof_id;
drivers/net/ice/base/ice_flow.h +1 -1
index bad925c8c..f0c74a348 100644
@@ -174,7 +174,7 @@ enum ice_flow_priority {
 
 struct ice_flow_seg_xtrct {
 	u8 prot_id;	/* Protocol ID of extracted header field */
-	u8 off;		/* Starting offset of the field in header in bytes */
+	u16 off;	/* Starting offset of the field in header in bytes */
 	u8 idx;		/* Index of FV entry used */
 	u8 disp;	/* Displacement of field in bits fr. FV entry's start */
 };
drivers/net/ice/base/ice_protocol_type.h +1 -1
index 6b3bd6542..e572dd320 100644
@@ -223,7 +223,7 @@ struct ice_prot_lkup_ext {
 	u16 prot_type;
 	u8 n_val_words;
 	/* create a buffer to hold max words per recipe */
-	u8 field_off[ICE_MAX_CHAIN_WORDS];
+	u16 field_off[ICE_MAX_CHAIN_WORDS];
 
 	struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
 
Signature · 1 line
2.13.6
#42 lore raw

Re: [PATCH 36/37] net/ice/base: increase prototol offset size

Quoted 1 line · Qi Zhang

Increase field vector's protocol offset size from 8 bit to 16 bit.

Same comment, I can see 'off' & 'field_off' storage size increased from u8 to u16.

But why? and what is the impact of it?

If someone from community hist a problem with this and wants to understand the code and changes, these commit logs will be valuable resources. Even you guys, a year later, if wants to understand why 'off' size is changed, this commit log won't be helpful at all.

Can you please check and revise all commit logs in this patchset?

Quoted 86 lines
---
 drivers/net/ice/base/ice_flex_type.h     | 8 +++++++-
 drivers/net/ice/base/ice_flow.c          | 7 +++++--
 drivers/net/ice/base/ice_flow.h          | 2 +-
 drivers/net/ice/base/ice_protocol_type.h | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_flex_type.h +7 -1
index 365f33390..f259e1371 100644
@@ -5,12 +5,18 @@
 #ifndef _ICE_FLEX_TYPE_H_
 #define _ICE_FLEX_TYPE_H_
 
+#define ICE_FV_OFFSET_INVAL    0x1FF
+
+#pragma pack(1)
 /* Extraction Sequence (Field Vector) Table */
 struct ice_fv_word {
 	u8 prot_id;
-	u8 off;		/* Offset within the protocol header */
+	u16 off;		/* Offset within the protocol header */
+	u8 resvrd;
 };
 
+#pragma pack()
+
 #define ICE_MAX_FV_WORDS 48
 struct ice_fv {
 	struct ice_fv_word ew[ICE_MAX_FV_WORDS];
drivers/net/ice/base/ice_flow.c +5 -2
index 98727cfeb..be819e0e9 100644
@@ -516,7 +516,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
 	struct ice_flow_fld_info *flds;
 	u16 cnt, ese_bits, i;
 	s16 adj = 0;
-	u8 off;
+	u16 off;
 
 	flds = params->prof->segs[seg].fields;
 
@@ -956,7 +956,10 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk,
 		return ICE_ERR_NO_MEMORY;
 
 	/* initialize extraction sequence to all invalid (0xff) */
-	ice_memset(params.es, 0xff, sizeof(params.es), ICE_NONDMA_MEM);
+	for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+		params.es[i].prot_id = ICE_PROT_INVALID;
+		params.es[i].off = ICE_FV_OFFSET_INVAL;
+	}
 
 	params.blk = blk;
 	params.prof->id = prof_id;
drivers/net/ice/base/ice_flow.h +1 -1
index bad925c8c..f0c74a348 100644
@@ -174,7 +174,7 @@ enum ice_flow_priority {
 
 struct ice_flow_seg_xtrct {
 	u8 prot_id;	/* Protocol ID of extracted header field */
-	u8 off;		/* Starting offset of the field in header in bytes */
+	u16 off;	/* Starting offset of the field in header in bytes */
 	u8 idx;		/* Index of FV entry used */
 	u8 disp;	/* Displacement of field in bits fr. FV entry's start */
 };
drivers/net/ice/base/ice_protocol_type.h +1 -1
index 6b3bd6542..e572dd320 100644
@@ -223,7 +223,7 @@ struct ice_prot_lkup_ext {
 	u16 prot_type;
 	u8 n_val_words;
 	/* create a buffer to hold max words per recipe */
-	u8 field_off[ICE_MAX_CHAIN_WORDS];
+	u16 field_off[ICE_MAX_CHAIN_WORDS];
 
 	struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
 
#43 lore raw

Re: [PATCH 36/37] net/ice/base: increase prototol offset size

Quoted 10 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 1, 2019 7:20 PM
To: Zhang, Qi Z <[email protected]>; Lu, Wenzhuo <[email protected]>; Yang, Qiming <[email protected]>
Cc: Stillwell Jr, Paul M <[email protected]>; [email protected]
Subject: Re: [PATCH 36/37] net/ice/base: increase prototol offset size

Quoted 6 lines
Quoted 1 line · Qi Zhang

Increase field vector's protocol offset size from 8 bit to 16 bit.

Same comment, I can see 'off' & 'field_off' storage size increased from u8 to u16.

But why? and what is the impact of it?

Since the format of OS package is changed, share code need to align with, I will add more detail information in v2.

Quoted 6 lines

If someone from community hist a problem with this and wants to understand the code and changes, these commit logs will be valuable resources. Even you guys, a year later, if wants to understand why 'off' size is changed, this commit log won't be helpful at all.

I agree with your point generally.

But just add more background here
ice in 19.02 is claimed as experimental release, quality is not guaranteed, it even does not download OS default package which is mandatory for real usage.

So we assume there will not be the case that "someone from community hit a problem in 19.02 and want to get help from commit log in 19.05 to root cause" And from our developer's view 19.05 is the real start, all commit log in share code before that is not quite sensitive. ( we even can simply regard this as an "initial commit")

But for release after 19.05, definitely we should statement each commit log carefully, since 19.05 will be validated carefully.

Quoted 1 line

Can you please check and revise all commit logs in this patchset?

Yes, I will check to see if anything can improved in v2.

Thanks
Qi

Quoted 90 lines

drivers/net/ice/base/ice_flow.c ice_flow_xtract_fld(struct ice_hw *hw, struct

Quoted 40 lines
---
 drivers/net/ice/base/ice_flex_type.h     | 8 +++++++-
 drivers/net/ice/base/ice_flow.c          | 7 +++++--
 drivers/net/ice/base/ice_flow.h          | 2 +-
 drivers/net/ice/base/ice_protocol_type.h | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_flex_type.h +7 -1
index 365f33390..f259e1371 100644
@@ -5,12 +5,18 @@
 #ifndef _ICE_FLEX_TYPE_H_
 #define _ICE_FLEX_TYPE_H_
 
+#define ICE_FV_OFFSET_INVAL    0x1FF
+
+#pragma pack(1)
 /* Extraction Sequence (Field Vector) Table */  struct ice_fv_word {
 	u8 prot_id;
-	u8 off;		/* Offset within the protocol header */
+	u16 off;		/* Offset within the protocol header */
+	u8 resvrd;
 };
 
+#pragma pack()
+
 #define ICE_MAX_FV_WORDS 48
 struct ice_fv {
 	struct ice_fv_word ew[ICE_MAX_FV_WORDS]; diff --git

a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c index 98727cfeb..be819e0e9 100644

drivers/net/ice/base/ice_flow.c +0 -0
@@ -516,7 +516,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct

ice_flow_prof_params *params,

drivers/net/ice/base/ice_flow.c ice_flow_add_prof_sync(struct ice_hw *hw, enum

Quoted 9 lines
drivers/net/ice/base/ice_flow.c +1 -1
 	struct ice_flow_fld_info *flds;
 	u16 cnt, ese_bits, i;
 	s16 adj = 0;
-	u8 off;
+	u16 off;
 
 	flds = params->prof->segs[seg].fields;
 
@@ -956,7 +956,10 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum

ice_block blk,

Quoted 39 lines
drivers/net/ice/base/ice_flow.c +4 -1
 		return ICE_ERR_NO_MEMORY;
 
 	/* initialize extraction sequence to all invalid (0xff) */
-	ice_memset(params.es, 0xff, sizeof(params.es), ICE_NONDMA_MEM);
+	for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+		params.es[i].prot_id = ICE_PROT_INVALID;
+		params.es[i].off = ICE_FV_OFFSET_INVAL;
+	}
 
 	params.blk = blk;
 	params.prof->id = prof_id;
(quoted diff) +0 -0

b/drivers/net/ice/base/ice_flow.h index bad925c8c..f0c74a348 100644

drivers/net/ice/base/ice_flow.h +1 -1
@@ -174,7 +174,7 @@ enum ice_flow_priority {
 
 struct ice_flow_seg_xtrct {
 	u8 prot_id;	/* Protocol ID of extracted header field */
-	u8 off;		/* Starting offset of the field in header in bytes */
+	u16 off;	/* Starting offset of the field in header in bytes */
 	u8 idx;		/* Index of FV entry used */
 	u8 disp;	/* Displacement of field in bits fr. FV entry's start */
 };
drivers/net/ice/base/ice_protocol_type.h +1 -1
index 6b3bd6542..e572dd320 100644
@@ -223,7 +223,7 @@ struct ice_prot_lkup_ext {
 	u16 prot_type;
 	u8 n_val_words;
 	/* create a buffer to hold max words per recipe */
-	u8 field_off[ICE_MAX_CHAIN_WORDS];
+	u16 field_off[ICE_MAX_CHAIN_WORDS];
 
 	struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
 
author
#44 lore raw

PATCH 37/37 net/ice/base: revert the workaround for resource allocation

In reply to Qi Zhang

Revert the workaround for allocating TCAM and FV entries to align with latest firmware.

---
 drivers/net/ice/base/ice_common.c    |  11 +-
 drivers/net/ice/base/ice_common.h    |   2 +-
 drivers/net/ice/base/ice_flex_pipe.c | 235 ++---------------------------------
 drivers/net/ice/base/ice_flex_type.h |   2 -
 4 files changed, 17 insertions(+), 233 deletions(-)
drivers/net/ice/base/ice_common.c +7 -4
index 74f925c03..3d2e5f347 100644
@@ -1786,11 +1786,11 @@ ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
  * @hw: pointer to the HW struct
  * @type: type of resource
  * @num: number of resources to allocate
- * @sh: shared if true, dedicated if false
+ * @btm: allocate from bottom
  * @res: pointer to array that will receive the resources
  */
 enum ice_status
-ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool sh, u16 *res)
+ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res)
 {
 	struct ice_aqc_alloc_free_res_elem *buf;
 	enum ice_status status;
@@ -1804,8 +1804,11 @@ ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool sh, u16 *res)
 
 	/* Prepare buffer to allocate resource. */
 	buf->num_elems = CPU_TO_LE16(num);
-	buf->res_type = CPU_TO_LE16(type | (sh ? ICE_AQC_RES_TYPE_FLAG_SHARED :
-		ICE_AQC_RES_TYPE_FLAG_DEDICATED));
+	buf->res_type = CPU_TO_LE16(type | ICE_AQC_RES_TYPE_FLAG_DEDICATED |
+				    ICE_AQC_RES_TYPE_FLAG_IGNORE_INDEX);
+	if (btm)
+		buf->res_type |= CPU_TO_LE16(ICE_AQC_RES_TYPE_FLAG_SCAN_BOTTOM);
+
 	status = ice_aq_alloc_free_res(hw, 1, buf, buf_len,
 				       ice_aqc_opc_alloc_res, NULL);
 	if (status)
drivers/net/ice/base/ice_common.h +1 -1
index 4dc43dcfe..e8f2ce9d8 100644
@@ -41,7 +41,7 @@ ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
 		enum ice_aq_res_access_type access, u32 timeout);
 void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);
 enum ice_status
-ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool sh, u16 *res);
+ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res);
 enum ice_status
 ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res);
 enum ice_status
drivers/net/ice/base/ice_flex_pipe.c +9 -226

292 lines not on this page · raw message

drivers/net/ice/base/ice_flex_type.h +0 -2
index f259e1371..f2a5f27e7 100644
@@ -507,7 +507,6 @@ struct ice_es {
 	u8 reverse; /* set to true to reverse FV order */
 	struct LIST_HEAD_TYPE prof_map;
 	struct ice_fv_word *t;
-	u8 *resource_used_hack; /* hack for testing */
 };
 
 /* PTYPE Group management */
@@ -660,7 +659,6 @@ struct ice_prof_tcam {
 	u16 max_prof_id;
 	u8 cdid_bits; /* # cdid bits to use in key, 0, 2, 4, or 8 */
 	struct ice_prof_tcam_entry *t;
-	u8 *resource_used_hack;
 };
 
 struct ice_prof_redir {
Signature · 1 line
2.13.6
author
#45 lore raw

v2 cover ice share code update.

In reply to Qi Zhang

Sync to latest kernel driver, main changes:
1. add DCB/FDIR support.
2. add more APIs in switch module.
3. code clean and bug fix.

v2:
- Enhanced the commit log.
- Add missing fixed line.

Qi Zhang (37):
net/ice/base: add switch resource allocation and free net/ice/base: improve comments
net/ice/base: add two helper functions net/ice/base: add helper macros
net/ice/base: allow package copy to be used after resets net/ice/base: code clean
net/ice/base: declare functions as external net/ice/base: add more APIs in switch module net/ice/base: add VSI queue context framework net/ice/base: add APIs to add remove ethertype filter net/ice/base: add APIs to get allocated resources net/ice/base: add APIs to alloc/free resource counter net/ice/base: add APIs to get VSI promiscuous mode net/ice/base: add MAC filter with marker and counter net/ice/base: add two helper functions for flow management net/ice/base: minor fix
net/ice/base: update macros
net/ice/base: code clean
net/ice/base: enable VSI queue context net/ice/base: ensure only valid bits are set net/ice/base: enhance get link status command net/ice/base: add RSS key related macro and structures net/ice/base: do not write TCAM entries back net/ice/base: remove local VSIG allocations net/ice/base: minor fix
net/ice/base: update copyright time
net/ice/base: fix static analysis reported issues net/ice/base: return config error without queue to disable net/ice/base: add function to check FW recovery mode net/ice/base: change profile id reference counting net/ice/base: add DCB support
net/ice/base: add FDIR support
net/ice/base: change profile priority for RSS reply net/ice/base: fix duplicate resource allocations net/ice/base: minor fix
net/ice/base: increase prototol offset size net/ice/base: revert the workaround for resource allocation

 drivers/net/ice/Makefile                 |    2 +
 drivers/net/ice/base/ice_adminq_cmd.h    |  515 +++++-
 drivers/net/ice/base/ice_alloc.h         |    2 +-
 drivers/net/ice/base/ice_common.c        |  650 ++++++--
 drivers/net/ice/base/ice_common.h        |   36 +-
 drivers/net/ice/base/ice_controlq.c      |   10 +-
 drivers/net/ice/base/ice_controlq.h      |    2 +-
 drivers/net/ice/base/ice_dcb.c           | 1393 ++++++++++++++++
 drivers/net/ice/base/ice_dcb.h           |  223 +++
 drivers/net/ice/base/ice_devids.h        |    2 +-
 drivers/net/ice/base/ice_fdir.c          |  742 +++++++++
 drivers/net/ice/base/ice_fdir.h          |  202 +++
 drivers/net/ice/base/ice_flex_pipe.c     | 1075 +++++++------
 drivers/net/ice/base/ice_flex_pipe.h     |    4 +-
 drivers/net/ice/base/ice_flex_type.h     |   19 +-
 drivers/net/ice/base/ice_flow.c          |  224 +--
 drivers/net/ice/base/ice_flow.h          |   22 +-
 drivers/net/ice/base/ice_hw_autogen.h    |    2 +-
 drivers/net/ice/base/ice_lan_tx_rx.h     |  149 +-
 drivers/net/ice/base/ice_nvm.c           |   17 +-
 drivers/net/ice/base/ice_osdep.h         |   16 +
 drivers/net/ice/base/ice_protocol_type.h |    8 +-
 drivers/net/ice/base/ice_sbq_cmd.h       |    2 +-
 drivers/net/ice/base/ice_sched.c         | 2563 +++++++++++++++---------------
 drivers/net/ice/base/ice_sched.h         |   34 +-
 drivers/net/ice/base/ice_status.h        |    3 +-
 drivers/net/ice/base/ice_switch.c        | 1315 ++++++++++++++-
 drivers/net/ice/base/ice_switch.h        |  109 +-
 drivers/net/ice/base/ice_type.h          |  119 +-
 drivers/net/ice/base/meson.build         |    2 +
 drivers/net/ice/ice_rxtx.c               |   11 +-
 31 files changed, 7111 insertions(+), 2362 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_dcb.c
 create mode 100644 drivers/net/ice/base/ice_dcb.h
 create mode 100644 drivers/net/ice/base/ice_fdir.c
 create mode 100644 drivers/net/ice/base/ice_fdir.h
Signature · 1 line
2.13.6
author
#46 lore raw

PATCH v2 1/37 net/ice/base: add switch resource allocation and free

Add two APIs ice_alloc_sw and ice_free_sw to support switch related resource allocation and free.

These APIs is required when we enable switch flow.

---
 drivers/net/ice/base/ice_switch.c | 150 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   5 ++
 2 files changed, 155 insertions(+)
drivers/net/ice/base/ice_switch.c +150 -0
index 0379cd045..a7b712e17 100644
@@ -129,6 +129,156 @@ ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp *buf,
 }
 
 
+/**
+ * ice_alloc_sw - allocate resources specific to switch
+ * @hw: pointer to the HW struct
+ * @ena_stats: true to turn on VEB stats
+ * @shared_res: true for shared resource, false for dedicated resource
+ * @sw_id: switch ID returned
+ * @counter_id: VEB counter ID returned
+ *
+ * allocates switch resources (SWID and VEB counter) (0x0208)
+ */
+enum ice_status
+ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
+	     u16 *counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf;
+	struct ice_aqc_res_elem *sw_ele;
+	enum ice_status status;
+	u16 buf_len;
+
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		   ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	/* Prepare buffer for switch ID.
+	 * The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is allocated, and hence a single sw_id
+	 * is requested.
+	 */
+	sw_buf->num_elems = CPU_TO_LE16(1);
+	sw_buf->res_type =
+		CPU_TO_LE16(ICE_AQC_RES_TYPE_SWID |
+			    (shared_res ? ICE_AQC_RES_TYPE_FLAG_SHARED :
+			    ICE_AQC_RES_TYPE_FLAG_DEDICATED));
+
+	status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+
+	if (status)
+		goto ice_alloc_sw_exit;
+
+	sw_ele = &sw_buf->elem[0];
+	*sw_id = LE16_TO_CPU(sw_ele->e.sw_resp);
+
+	if (ena_stats) {
+		/* Prepare buffer for VEB Counter */
+		enum ice_adminq_opc opc = ice_aqc_opc_alloc_res;
+		struct ice_aqc_alloc_free_res_elem *counter_buf;
+		struct ice_aqc_res_elem *counter_ele;
+
+		counter_buf = (struct ice_aqc_alloc_free_res_elem *)
+				ice_malloc(hw, buf_len);
+		if (!counter_buf) {
+			status = ICE_ERR_NO_MEMORY;
+			goto ice_alloc_sw_exit;
+		}
+
+		/* The number of resource entries in buffer is passed as 1 since
+		 * only a single switch/VEB instance is allocated, and hence a
+		 * single VEB counter is requested.
+		 */
+		counter_buf->num_elems = CPU_TO_LE16(1);
+		counter_buf->res_type =
+			CPU_TO_LE16(ICE_AQC_RES_TYPE_VEB_COUNTER |
+				    ICE_AQC_RES_TYPE_FLAG_DEDICATED);
+		status = ice_aq_alloc_free_res(hw, 1, counter_buf, buf_len,
+					       opc, NULL);
+
+		if (status) {
+			ice_free(hw, counter_buf);
+			goto ice_alloc_sw_exit;
+		}
+		counter_ele = &counter_buf->elem[0];
+		*counter_id = LE16_TO_CPU(counter_ele->e.sw_resp);
+		ice_free(hw, counter_buf);
+	}
+
+ice_alloc_sw_exit:
+	ice_free(hw, sw_buf);
+	return status;
+}
+
+/**
+ * ice_free_sw - free resources specific to switch
+ * @hw: pointer to the HW struct
+ * @sw_id: switch ID returned
+ * @counter_id: VEB counter ID returned
+ *
+ * free switch resources (SWID and VEB counter) (0x0209)
+ *
+ * NOTE: This function frees multiple resources. It continues
+ * releasing other resources even after it encounters error.
+ * The error code returned is the last error it encountered.
+ */
+enum ice_status ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf, *counter_buf;
+	enum ice_status status, ret_status;
+	u16 buf_len;
+
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		   ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	/* Prepare buffer to free for switch ID res.
+	 * The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is freed, and hence a single sw_id
+	 * is released.
+	 */
+	sw_buf->num_elems = CPU_TO_LE16(1);
+	sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_SWID);
+	sw_buf->elem[0].e.sw_resp = CPU_TO_LE16(sw_id);
+
+	ret_status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+					   ice_aqc_opc_free_res, NULL);
+
+	if (ret_status)
+		ice_debug(hw, ICE_DBG_SW, "CQ CMD Buffer:\n");
+
+	/* Prepare buffer to free for VEB Counter resource */
+	counter_buf = (struct ice_aqc_alloc_free_res_elem *)
+			ice_malloc(hw, buf_len);
+	if (!counter_buf) {
+		ice_free(hw, sw_buf);
+		return ICE_ERR_NO_MEMORY;
+	}
+
+	/* The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is freed, and hence a single VEB counter
+	 * is released
+	 */
+	counter_buf->num_elems = CPU_TO_LE16(1);
+	counter_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_VEB_COUNTER);
+	counter_buf->elem[0].e.sw_resp = CPU_TO_LE16(counter_id);
+
+	status = ice_aq_alloc_free_res(hw, 1, counter_buf, buf_len,
+				       ice_aqc_opc_free_res, NULL);
+	if (status) {
+		ice_debug(hw, ICE_DBG_SW,
+			  "VEB counter resource could not be freed\n");
+		ret_status = status;
+	}
+
+	ice_free(hw, counter_buf);
+	ice_free(hw, sw_buf);
+	return ret_status;
+}
 
 /**
  * ice_aq_add_vsi
drivers/net/ice/base/ice_switch.h +5 -0
index 66a172fc2..dd21781f7 100644
@@ -290,6 +290,11 @@ ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
 /* Switch/bridge related commands */
 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
 enum ice_status
+ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
+	     u16 *counter_id);
+enum ice_status
+ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id);
+enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
Signature · 1 line
2.13.6
author
#47 lore raw

PATCH v2 2/37 net/ice/base: improve comments

In reply to Qi Zhang

Improve comments to follow naming rules.
Also the patch include some minor cleanup.

---
 drivers/net/ice/base/ice_adminq_cmd.h    |  27 +-
 drivers/net/ice/base/ice_common.c        | 148 +++----
 drivers/net/ice/base/ice_common.h        |   4 +-
 drivers/net/ice/base/ice_controlq.c      |   8 +-
 drivers/net/ice/base/ice_flex_pipe.c     | 364 ++++++++--------
 drivers/net/ice/base/ice_flex_pipe.h     |   2 +-
 drivers/net/ice/base/ice_flex_type.h     |   4 +-
 drivers/net/ice/base/ice_flow.c          |  65 +--
 drivers/net/ice/base/ice_flow.h          |   1 -
 drivers/net/ice/base/ice_lan_tx_rx.h     |  70 +--
 drivers/net/ice/base/ice_nvm.c           |   8 +-
 drivers/net/ice/base/ice_protocol_type.h |   4 +-
 drivers/net/ice/base/ice_sched.c         | 719 ++++++++++++++++---------------
 drivers/net/ice/base/ice_sched.h         |   8 +-
 drivers/net/ice/base/ice_switch.c        | 120 +++---
 drivers/net/ice/base/ice_switch.h        |  20 +-
 drivers/net/ice/base/ice_type.h          |  34 +-
 17 files changed, 804 insertions(+), 802 deletions(-)
drivers/net/ice/base/ice_adminq_cmd.h +13 -14
index a1b9edd14..5a599280e 100644
@@ -71,7 +71,7 @@ struct ice_aqc_req_res {
 #define ICE_AQ_RES_NVM_WRITE_DFLT_TIMEOUT_MS	180000
 #define ICE_AQ_RES_CHNG_LOCK_DFLT_TIMEOUT_MS	1000
 #define ICE_AQ_RES_GLBL_LOCK_DFLT_TIMEOUT_MS	3000
-	/* For SDP: pin id of the SDP */
+	/* For SDP: pin ID of the SDP */
 	__le32 res_number;
 	/* Status is only used for ICE_AQC_RES_ID_GLBL_LOCK */
 	__le16 status;
@@ -854,7 +854,6 @@ struct ice_aqc_delete_elem {
 
 
 
-
 /* Rate limiting profile for
  * Add RL profile (indirect 0x0410)
  * Query RL profile (indirect 0x0411)
@@ -1154,8 +1153,8 @@ struct ice_aqc_set_phy_cfg_data {
 	__le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */
 	__le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */
 	u8 caps;
-#define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY		BIT(0)
-#define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY		BIT(1)
+#define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY	BIT(0)
+#define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY	BIT(1)
 #define ICE_AQ_PHY_ENA_LOW_POWER	BIT(2)
 #define ICE_AQ_PHY_ENA_LINK		BIT(3)
 #define ICE_AQ_PHY_ENA_AUTO_LINK_UPDT	BIT(5)
@@ -1228,7 +1227,7 @@ struct ice_aqc_get_link_status_data {
 	u8 ext_info;
 #define ICE_AQ_LINK_PHY_TEMP_ALARM	BIT(0)
 #define ICE_AQ_LINK_EXCESSIVE_ERRORS	BIT(1)	/* Excessive Link Errors */
-	/* Port TX Suspended */
+	/* Port Tx Suspended */
 #define ICE_AQ_LINK_TX_S		2
 #define ICE_AQ_LINK_TX_M		(0x03 << ICE_AQ_LINK_TX_S)
 #define ICE_AQ_LINK_TX_ACTIVE		0
@@ -1441,7 +1440,7 @@ struct ice_aqc_get_set_rss_lut {
 
 
 
-/* Add TX LAN Queues (indirect 0x0C30) */
+/* Add Tx LAN Queues (indirect 0x0C30) */
 struct ice_aqc_add_txqs {
 	u8 num_qgrps;
 	u8 reserved[3];
@@ -1451,7 +1450,7 @@ struct ice_aqc_add_txqs {
 };
 
 
-/* This is the descriptor of each queue entry for the Add TX LAN Queues
+/* This is the descriptor of each queue entry for the Add Tx LAN Queues
  * command (0x0C30). Only used within struct ice_aqc_add_tx_qgrp.
  */
 struct ice_aqc_add_txqs_perq {
@@ -1464,7 +1463,7 @@ struct ice_aqc_add_txqs_perq {
 };
 
 
-/* The format of the command buffer for Add TX LAN Queues (0x0C30)
+/* The format of the command buffer for Add Tx LAN Queues (0x0C30)
  * is an array of the following structs. Please note that the length of
  * each struct ice_aqc_add_tx_qgrp is variable due
  * to the variable number of queues in each group!
@@ -1477,7 +1476,7 @@ struct ice_aqc_add_tx_qgrp {
 };
 
 
-/* Disable TX LAN Queues (indirect 0x0C31) */
+/* Disable Tx LAN Queues (indirect 0x0C31) */
 struct ice_aqc_dis_txqs {
 	u8 cmd_type;
 #define ICE_AQC_Q_DIS_CMD_S		0
@@ -1500,7 +1499,7 @@ struct ice_aqc_dis_txqs {
 };
 
 
-/* The buffer for Disable TX LAN Queues (indirect 0x0C31)
+/* The buffer for Disable Tx LAN Queues (indirect 0x0C31)
  * contains the following structures, arrayed one after the
  * other.
  * Note: Since the q_id is 16 bits wide, if the
@@ -1528,7 +1527,7 @@ struct ice_aqc_dis_txq {
 };
 
 
-/* TX LAN Queues Cleanup Event (0x0C31) */
+/* Tx LAN Queues Cleanup Event (0x0C31) */
 struct ice_aqc_txqs_cleanup {
 	__le16 caller_opc;
 	__le16 cmd_tag;
@@ -1536,7 +1535,7 @@ struct ice_aqc_txqs_cleanup {
 };
 
 
-/* Move / Reconfigure TX Queues (indirect 0x0C32) */
+/* Move / Reconfigure Tx Queues (indirect 0x0C32) */
 struct ice_aqc_move_txqs {
 	u8 cmd_type;
 #define ICE_AQC_Q_CMD_TYPE_S		0
@@ -1557,7 +1556,7 @@ struct ice_aqc_move_txqs {
 };
 
 
-/* This is the descriptor of each queue entry for the move TX LAN Queues
+/* This is the descriptor of each queue entry for the move Tx LAN Queues
  * command (0x0C32).
  */
 struct ice_aqc_move_txqs_elem {
@@ -1950,7 +1949,7 @@ enum ice_adminq_opc {
 	ice_aqc_opc_get_rss_key				= 0x0B04,
 	ice_aqc_opc_get_rss_lut				= 0x0B05,
 
-	/* TX queue handling commands/events */
+	/* Tx queue handling commands/events */
 	ice_aqc_opc_add_txqs				= 0x0C30,
 	ice_aqc_opc_dis_txqs				= 0x0C31,
 	ice_aqc_opc_txqs_cleanup			= 0x0C31,
drivers/net/ice/base/ice_common.c +74 -74

516 lines not on this page · raw message

drivers/net/ice/base/ice_common.h +1 -3
index 5ac991ef2..f2ad86182 100644
@@ -61,8 +61,7 @@ enum ice_status ice_get_caps(struct ice_hw *hw);
  * ... the value of pointer would equal 0x1008, since 0x1008 is the next
  * address after 0x1006 which is divisible by 4.
  */
-#define ICE_ALIGN(ptr, align)   (((ptr) + ((align) - 1)) & ~((align) - 1))
-
+#define ICE_ALIGN(ptr, align)	(((ptr) + ((align) - 1)) & ~((align) - 1))
 
 enum ice_status
 ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx,
@@ -149,7 +148,6 @@ ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 
 
 
-
 enum ice_status
 ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
drivers/net/ice/base/ice_controlq.c +4 -4
index cbc4cb4c2..1c0830cec 100644
@@ -54,7 +54,7 @@ static void ice_mailbox_init_regs(struct ice_hw *hw)
 
 /**
  * ice_check_sq_alive
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  *
  * Returns true if Queue is enabled else false.
@@ -729,7 +729,7 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 
 /**
  * ice_sq_done - check if FW has processed the Admin Send Queue (ATQ)
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  *
  * Returns true if the firmware has processed all descriptors on the
@@ -745,7 +745,7 @@ static bool ice_sq_done(struct ice_hw *hw, struct ice_ctl_q_info *cq)
 
 /**
  * ice_sq_send_cmd - send command to Control Queue (ATQ)
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  * @desc: prefilled descriptor describing the command (non DMA mem)
  * @buf: buffer to use for indirect commands (or NULL for direct commands)
@@ -990,7 +990,7 @@ void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode)
 
 /**
  * ice_clean_rq_elem
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @cq: pointer to the specific Control queue
  * @e: event info from the receive descriptor, includes any buffers
  * @pending: number of events that could be left to process
drivers/net/ice/base/ice_flex_pipe.c +182 -182

999 lines not on this page · raw message

drivers/net/ice/base/ice_flex_pipe.h +1 -1
index 81e89aeeb..23fffed75 100644
@@ -59,7 +59,7 @@ void ice_ptg_free(struct ice_hw *hw, enum ice_block blk, u8 ptg);
 enum ice_status
 ice_ptg_add_mv_ptype(struct ice_hw *hw, enum ice_block blk, u16 ptype, u8 ptg);
 
-/* XLT2/Vsi group functions */
+/* XLT2/VSI group functions */
 enum ice_status ice_vsig_update_xlt2(struct ice_hw *hw, enum ice_block blk);
 enum ice_status
 ice_vsig_find_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 *vsig);
drivers/net/ice/base/ice_flex_type.h +2 -2
index 9f98f4f2a..aed23a067 100644
@@ -350,7 +350,7 @@ struct ice_sw_fv_list_entry {
 };
 
 #pragma pack(1)
-/* The BOOST tcam stores the match packet header in reverse order, meaning
+/* The BOOST TCAM stores the match packet header in reverse order, meaning
  * the fields are reversed; in addition, this means that the normally big endian
  * fields of the packet are now little endian.
  */
@@ -602,7 +602,7 @@ struct ice_xlt2 {
 };
 
 /* Extraction sequence - list of match fields:
- * protocol id, offset, profile length
+ * protocol ID, offset, profile length
  */
 union ice_match_fld {
 	struct {
drivers/net/ice/base/ice_flow.c +34 -31

231 lines not on this page · raw message

drivers/net/ice/base/ice_flow.h +0 -1
index 51d7c3ac9..265e1ee3e 100644
@@ -227,7 +227,6 @@ struct ice_flow_entry {
 	u64 id;
 	u16 vsi_handle;
 	enum ice_flow_priority priority;
-
 	struct ice_flow_prof *prof;
 
 	/* Flow entry's content */
drivers/net/ice/base/ice_lan_tx_rx.h +35 -35

170 lines not on this page · raw message

drivers/net/ice/base/ice_nvm.c +4 -4
index 25a2ca4cb..92de2ec3b 100644
@@ -7,7 +7,7 @@
 
 /**
  * ice_aq_read_nvm
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @module_typeid: module pointer location in words from the NVM beginning
  * @offset: byte offset from the module beginning
  * @length: length of the section to be read (in bytes from the offset)
@@ -248,7 +248,7 @@ enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data)
 
 /**
  * ice_init_nvm - initializes NVM setting
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  *
  * This function reads and populates NVM settings such as Shadow RAM size,
  * max_timeout, and blank_nvm_mode
@@ -264,7 +264,7 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)
 
 	ice_debug(hw, ICE_DBG_TRACE, "ice_init_nvm");
 
-	/* The SR size is stored regardless of the nvm programming mode
+	/* The SR size is stored regardless of the NVM programming mode
 	 * as the blank mode may be used in the factory line.
 	 */
 	gens_stat = rd32(hw, GLNVM_GENS);
@@ -357,7 +357,7 @@ ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
 
 /**
  * ice_nvm_validate_checksum
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  *
  * Verify NVM PFA checksum validity (0x0706)
  */
drivers/net/ice/base/ice_protocol_type.h +2 -2
index 7b92c7105..f96964d86 100644
@@ -18,7 +18,7 @@
 /* Max recipes that can be chained */
 #define ICE_MAX_CHAIN_RECIPE 5
 
-/* 1 word reserved for switch id from allowed 5 words.
+/* 1 word reserved for switch ID from allowed 5 words.
  * So a recipe can have max 4 words. And you can chain 5 such recipes
  * together. So maximum words that can be programmed for look up is 5 * 4.
  */
@@ -128,7 +128,7 @@ enum ice_prot_id {
 
 #define ICE_PROTOCOL_MAX_ENTRIES 16
 
-/* Mapping of software defined protocol id to hardware defined protocol id */
+/* Mapping of software defined protocol ID to hardware defined protocol ID */
 struct ice_protocol_entry {
 	enum ice_protocol_type type;
 	u8 protocol_id;
drivers/net/ice/base/ice_sched.c +360 -359

852 lines not on this page · raw message

drivers/net/ice/base/ice_sched.h +4 -4
index a5565945e..61fa6a85b 100644

Lines of this file are not shown. View the raw message.

drivers/net/ice/base/ice_switch.c +60 -60

120 lines not on this page · raw message

drivers/net/ice/base/ice_switch.h +11 -9
index dd21781f7..90dfdabcb 100644

Lines of this file are not shown. View the raw message.

drivers/net/ice/base/ice_type.h +17 -17
index 17d79ba21..08c974004 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.13.6

Part of the diff is not shown here. View the raw message.

author
#48 lore raw

PATCH v2 3/37 net/ice/base: add two helper functions

In reply to Qi Zhang

Add two helper functions in common module.
1. ice_aq_set_mac_cfg to help configure maximum frame size with AQ command
2. ice_get_ctx help to extract context bits from a packet structure.

---
 drivers/net/ice/base/ice_adminq_cmd.h |  20 +++
 drivers/net/ice/base/ice_common.c     | 282 ++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_common.h     |   4 +
 3 files changed, 306 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +20 -0
index 5a599280e..feb980475 100644
@@ -1168,6 +1168,25 @@ struct ice_aqc_set_phy_cfg_data {
 };
 
 
+/* Set MAC Config command data structure (direct 0x0603) */
+struct ice_aqc_set_mac_cfg {
+	__le16 max_frame_size;
+	u8 params;
+#define ICE_AQ_SET_MAC_PACE_S		3
+#define ICE_AQ_SET_MAC_PACE_M		(0xF << ICE_AQ_SET_MAC_PACE_S)
+#define ICE_AQ_SET_MAC_PACE_TYPE_M	BIT(7)
+#define ICE_AQ_SET_MAC_PACE_TYPE_RATE	0
+#define ICE_AQ_SET_MAC_PACE_TYPE_FIXED	ICE_AQ_SET_MAC_PACE_TYPE_M
+	u8 tx_tmr_priority;
+	__le16 tx_tmr_value;
+	__le16 fc_refresh_threshold;
+	u8 drop_opts;
+#define ICE_AQ_SET_MAC_AUTO_DROP_MASK		BIT(0)
+#define ICE_AQ_SET_MAC_AUTO_DROP_NONE		0
+#define ICE_AQ_SET_MAC_AUTO_DROP_BLOCKING_PKTS	BIT(0)
+	u8 reserved[7];
+};
+
 
 /* Restart AN command data structure (direct 0x0605)
  * Also used for response, with only the lport_num field present.
@@ -1782,6 +1801,7 @@ struct ice_aq_desc {
 		struct ice_aqc_get_clear_fw_log get_clear_fw_log;
 		struct ice_aqc_set_mac_lb set_mac_lb;
 		struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
+		struct ice_aqc_set_mac_cfg set_mac_cfg;
 		struct ice_aqc_set_event_mask set_event_mask;
 		struct ice_aqc_get_link_status get_link_status;
 	} params;
drivers/net/ice/base/ice_common.c +282 -0

294 lines not on this page · raw message

drivers/net/ice/base/ice_common.h +4 -0
index f2ad86182..0b387cdbe 100644
@@ -133,6 +133,8 @@ enum ice_status
 ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
 			   struct ice_sq_cd *cd);
 enum ice_status
+ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd);
+enum ice_status
 ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
 		     struct ice_link_status *link, struct ice_sq_cd *cd);
 enum ice_status
@@ -149,6 +151,8 @@ ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 
 
 enum ice_status
+ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info);
+enum ice_status
 ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
 		struct ice_sq_cd *cmd_details);
Signature · 1 line
2.13.6
author
#49 lore raw

PATCH v2 4/37 net/ice/base: add helper macros

In reply to Qi Zhang

1. Add macro ice_for_each_traffic_class to loop for each traffic class.
2. Add macro MIN_T to wrap min with type conversion.

---
 drivers/net/ice/base/ice_common.c |  2 +-
 drivers/net/ice/base/ice_nvm.c    |  7 ++++---
 drivers/net/ice/base/ice_sched.c  | 30 +++++++++++++++---------------
 drivers/net/ice/base/ice_type.h   |  7 +++++++
 4 files changed, 27 insertions(+), 19 deletions(-)
drivers/net/ice/base/ice_common.c +1 -1
index 392183375..86d3be17a 100644
@@ -3669,7 +3669,7 @@ ice_cfg_vsi_qs(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
 
 	ice_acquire_lock(&pi->sched_lock);
 
-	for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
+	ice_for_each_traffic_class(i) {
 		/* configuration is possible only if TC node is present */
 		if (!ice_sched_get_tc_node(pi, i))
 			continue;
drivers/net/ice/base/ice_nvm.c +4 -3
index 92de2ec3b..8d3d0b0ed 100644
@@ -163,9 +163,10 @@ ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
 		 */
 		off_w = offset % ICE_SR_SECTOR_SIZE_IN_WORDS;
 		read_size = off_w ?
-			min(*words,
-			    (u16)(ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
-			min((*words - words_read), ICE_SR_SECTOR_SIZE_IN_WORDS);
+			MIN_T(u16, *words,
+			      (ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
+			MIN_T(u16, (*words - words_read),
+			      ICE_SR_SECTOR_SIZE_IN_WORDS);
 
 		/* Check if this is last command, if so set proper flag */
 		if ((words_read + read_size) >= *words)
drivers/net/ice/base/ice_sched.c +15 -15
index 2edc305b5..237bf7350 100644
@@ -1896,7 +1896,7 @@ ice_sched_rm_vsi_cfg(struct ice_port_info *pi, u16 vsi_handle, u8 owner)
 	if (!vsi_ctx)
 		goto exit_sched_rm_vsi_cfg;
 
-	for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
+	ice_for_each_traffic_class(i) {
 		struct ice_sched_node *vsi_node, *tc_node;
 		u8 j = 0;
 
@@ -2174,7 +2174,7 @@ ice_sched_cfg_agg(struct ice_port_info *pi, u32 agg_id,
 		LIST_ADD(&agg_info->list_entry, &hw->agg_list);
 	}
 	/* Create aggregator node(s) for requested TC(s) */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_tc_ena(*tc_bitmap, tc)) {
 			/* Delete aggregator cfg TC if it exists previously */
 			status = ice_rm_agg_cfg_tc(pi, agg_info, tc, false);
@@ -2340,7 +2340,7 @@ ice_sched_assoc_vsi_to_agg(struct ice_port_info *pi, u32 agg_id,
 		LIST_ADD(&agg_vsi_info->list_entry, &agg_info->agg_vsi_list);
 	}
 	/* Move VSI node to new aggregator node for requested TC(s) */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_tc_ena(*tc_bitmap, tc))
 			continue;
 
@@ -2410,7 +2410,7 @@ enum ice_status ice_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id)
 		goto exit_ice_rm_agg_cfg;
 	}
 
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		status = ice_rm_agg_cfg_tc(pi, agg_info, tc, true);
 		if (status)
 			goto exit_ice_rm_agg_cfg;
@@ -3050,7 +3050,7 @@ ice_cfg_vsi_bw_alloc(struct ice_port_info *pi, u16 vsi_handle, u8 ena_tcmap,
 	ice_acquire_lock(&pi->sched_lock);
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *vsi_node;
 
 		if (!ice_is_tc_ena(ena_tcmap, tc))
@@ -3112,7 +3112,7 @@ ice_cfg_agg_bw_alloc(struct ice_port_info *pi, u32 agg_id, u8 ena_tcmap,
 	}
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *agg_node;
 
 		if (!ice_is_tc_ena(ena_tcmap, tc))
@@ -4174,7 +4174,7 @@ ice_sched_set_agg_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle)
 	if (!vsi_ctx)
 		return ICE_ERR_PARAM;
 
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *node;
 
 		node = vsi_ctx->sched.ag_node[tc];
@@ -4324,7 +4324,7 @@ ice_sched_validate_vsi_srl_node(struct ice_port_info *pi, u16 vsi_handle)
 		return ICE_ERR_PARAM;
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *vsi_node;
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 		enum ice_status status;
@@ -4384,7 +4384,7 @@ ice_sched_set_vsi_bw_shared_lmt(struct ice_port_info *pi, u16 vsi_handle,
 	if (status)
 		goto exit_set_vsi_bw_shared_lmt;
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *vsi_node;
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 
@@ -4442,7 +4442,7 @@ ice_sched_validate_agg_srl_node(struct ice_port_info *pi, u32 agg_id)
 	if (!agg_id_present)
 		return ICE_ERR_PARAM;
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node, *agg_node;
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 
@@ -4513,7 +4513,7 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
 	}
 
 	/* Return success if no nodes are present across TC */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		enum ice_rl_type rl_type = ICE_SHARED_BW;
 		struct ice_sched_node *tc_node, *agg_node;
 
@@ -5119,7 +5119,7 @@ ice_sched_replay_agg_bw(struct ice_hw *hw, struct ice_sched_agg_info *agg_info)
 
 	if (!agg_info)
 		return ICE_ERR_PARAM;
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_any_bit_set(agg_info->bw_t_info[tc].bw_t_bitmap,
 					ICE_BW_TYPE_CNT))
 			continue;
@@ -5159,7 +5159,7 @@ ice_sched_get_ena_tc_bitmap(struct ice_port_info *pi, ice_bitmap_t *tc_bitmap,
 	u8 tc;
 
 	/* Some TC(s) may be missing after reset, adjust for replay */
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++)
+	ice_for_each_traffic_class(tc)
 		if (ice_is_tc_ena(*tc_bitmap, tc) &&
 		    (ice_sched_get_tc_node(pi, tc)))
 			ice_set_bit(tc, ena_tc_bitmap);
@@ -5253,7 +5253,7 @@ ice_sched_replay_tc_node_bw(struct ice_hw *hw)
 	u8 tc;
 
 	ice_acquire_lock(&pi->sched_lock);
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		struct ice_sched_node *tc_node;
 
 		tc_node = ice_sched_get_tc_node(hw->port_info, tc);
@@ -5291,7 +5291,7 @@ ice_sched_replay_vsi_bw(struct ice_hw *hw, u16 vsi_handle,
 	vsi_ctx = ice_get_vsi_ctx(pi->hw, vsi_handle);
 	if (!vsi_ctx)
 		return ICE_ERR_PARAM;
-	for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
+	ice_for_each_traffic_class(tc) {
 		if (!ice_is_tc_ena(*tc_bitmap, tc))
 			continue;
 		tc_node = ice_sched_get_tc_node(pi, tc);
drivers/net/ice/base/ice_type.h +7 -0
index 08c974004..2e865a78f 100644
@@ -18,6 +18,9 @@
 #define ICE_BYTES_PER_DWORD	4
 #define ICE_MAX_TRAFFIC_CLASS	8
 
+#ifndef MIN_T
+#define MIN_T(_t, _a, _b)	min((_t)(_a), (_t)(_b))
+#endif
 
 #include "ice_status.h"
 #include "ice_hw_autogen.h"
@@ -379,6 +382,10 @@ struct ice_nvm_info {
 
 /* Max number of port to queue branches w.r.t topology */
 #define ICE_TXSCHED_MAX_BRANCHES ICE_MAX_TRAFFIC_CLASS
+
+#define ice_for_each_traffic_class(_i)	\
+	for ((_i) = 0; (_i) < ICE_MAX_TRAFFIC_CLASS; (_i)++)
+
 /* ICE_DFLT_AGG_ID means that all new VM(s)/VSI node connects
  * to driver defined policy for default aggregator
  */
Signature · 1 line
2.13.6
author
#50 lore raw

PATCH v2 5/37 net/ice/base: allow package copy to be used after resets

In reply to Qi Zhang

For components that make a copy of an external pipeline package file (i.e. the Linux and FreeBSD drivers), save the size of the package file along with the copy so that both can be used when calling ice_init_pkg() after a CORER/GLOBR reset. Also, do not free the copy of the package file in ice_init_pkg() since it is needed afterward for subsequent resets.

---
 drivers/net/ice/base/ice_flex_pipe.c | 9 +++++----
 drivers/net/ice/base/ice_type.h      | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +5 -4
index c87424601..66c47abda 100644
@@ -1269,6 +1269,7 @@ void ice_free_seg(struct ice_hw *hw)
 	if (hw->pkg_copy) {
 		ice_free(hw, hw->pkg_copy);
 		hw->pkg_copy = NULL;
+		hw->pkg_size = 0;
 	}
 	hw->seg = NULL;
 }
@@ -1351,8 +1352,6 @@ static enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
 		status = ICE_SUCCESS;
 	}
 
-	/* Free a previous segment, if necessary */
-	ice_free_seg(hw);
 	if (!status) {
 		hw->seg = seg;
 		/* on successful package download, update other required
@@ -1401,12 +1400,14 @@ enum ice_status ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len)
 	buf_copy = (u8 *)ice_memdup(hw, buf, len, ICE_NONDMA_TO_NONDMA);
 
 	status = ice_init_pkg(hw, buf_copy, len);
-	if (status)
+	if (status) {
 		/* Free the copy, since we failed to initialize the package */
 		ice_free(hw, buf_copy);
-	else
+	} else {
 		/* Track the copied pkg so we can free it later */
 		hw->pkg_copy = buf_copy;
+		hw->pkg_size = len;
+	}
 
 	return status;
 }
drivers/net/ice/base/ice_type.h +1 -0
index 2e865a78f..6bd73ed04 100644
@@ -728,6 +728,7 @@ struct ice_hw {
 
 	/* Pointer to allocated copy of pkg memory */
 	u8 *pkg_copy;
+	u32 pkg_size;
 
 	/* tunneling info */
 	struct ice_tunnel_table tnl;
Signature · 1 line
2.13.6
author
#51 lore raw

PATCH v2 6/37 net/ice/base: code clean

In reply to Qi Zhang

Remove unnecessary macro and data structure.

---
 drivers/net/ice/base/ice_adminq_cmd.h |   2 -
 drivers/net/ice/base/ice_flex_pipe.c  |   2 -
 drivers/net/ice/base/ice_flow.c       | 136 ----------------------------------
 drivers/net/ice/base/ice_type.h       |   6 --
 4 files changed, 146 deletions(-)
drivers/net/ice/base/ice_adminq_cmd.h +0 -2
index feb980475..056a9fbef 100644
@@ -1930,8 +1930,6 @@ enum ice_adminq_opc {
 	ice_aqc_opc_move_sched_elems			= 0x0408,
 	ice_aqc_opc_suspend_sched_elems			= 0x0409,
 	ice_aqc_opc_resume_sched_elems			= 0x040A,
-	ice_aqc_opc_suspend_sched_traffic		= 0x040B,
-	ice_aqc_opc_resume_sched_traffic		= 0x040C,
 	ice_aqc_opc_delete_sched_elems			= 0x040F,
 	ice_aqc_opc_add_rl_profiles			= 0x0410,
 	ice_aqc_opc_query_rl_profiles			= 0x0411,
drivers/net/ice/base/ice_flex_pipe.c +0 -2
index 66c47abda..2d23c36eb 100644
@@ -2247,8 +2247,6 @@ ice_find_dup_props_vsig(struct ice_hw *hw, enum ice_block blk,
 	for (i = 0; i < xlt2->count; i++) {
 		if (xlt2->vsig_tbl[i].in_use &&
 		    ice_match_prop_lst(chs, &xlt2->vsig_tbl[i].prop_lst)) {
-			*vsig = (i | ((hw->pf_id << ICE_PF_NUM_S) &
-				      ICE_PF_NUM_M));
 			*vsig = ICE_VSIG_VALUE(i, hw->pf_id);
 			return ICE_SUCCESS;
 		}
drivers/net/ice/base/ice_flow.c +0 -136

142 lines not on this page · raw message

drivers/net/ice/base/ice_type.h +0 -6
index 6bd73ed04..25d64477f 100644
@@ -733,12 +733,6 @@ struct ice_hw {
 	/* tunneling info */
 	struct ice_tunnel_table tnl;
 
-	/* PTYPE group and XLT1 management */
-#define ICE_MAX_PTGS	256
-	struct ice_ptg_entry ptg_tbl[ICE_BLK_COUNT][ICE_MAX_PTGS];
-
-#define ICE_XLT1_CNT	1024
-	struct ice_ptg_ptype xlt1_tbl[ICE_BLK_COUNT][ICE_XLT1_CNT];
 #define ICE_PKG_FILENAME	"package_file"
 #define ICE_PKG_FILENAME_EXT	"pkg"
 #define ICE_PKG_FILE_MAJ_VER	1
Signature · 1 line
2.13.6
author
#52 lore raw

PATCH v2 7/37 net/ice/base: declare functions as external

In reply to Qi Zhang

Remove static of below functions and declare them as external APIs.

ice_aq_add_vsi
ice_aq_free_vsi
ice_aq_update_vsi
ice_aq_add_lan_txq
ice_init_pkg

So far the purpose is just to sync with kernel driver. They are reserved for future use.

---
 drivers/net/ice/base/ice_common.c    | 2 +-
 drivers/net/ice/base/ice_common.h    | 4 ++++
 drivers/net/ice/base/ice_flex_pipe.c | 2 +-
 drivers/net/ice/base/ice_flex_pipe.h | 2 ++
 drivers/net/ice/base/ice_switch.c    | 6 +++---
 drivers/net/ice/base/ice_switch.h    | 9 +++++++++
 6 files changed, 20 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_common.c +1 -1
index 86d3be17a..015db11e0 100644
@@ -2935,7 +2935,7 @@ ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
  * Association of Tx queue to Doorbell queue is not part of Add LAN Tx queue
  * flow.
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_lan_txq(struct ice_hw *hw, u8 num_qgrps,
 		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
 		   struct ice_sq_cd *cd)
drivers/net/ice/base/ice_common.h +4 -0
index 0b387cdbe..63f4a5ebe 100644
@@ -94,6 +94,10 @@ ice_aq_get_rss_key(struct ice_hw *hw, u16 vsi_handle,
 enum ice_status
 ice_aq_set_rss_key(struct ice_hw *hw, u16 vsi_handle,
 		   struct ice_aqc_get_set_rss_keys *keys);
+enum ice_status
+ice_aq_add_lan_txq(struct ice_hw *hw, u8 count,
+		   struct ice_aqc_add_tx_qgrp *qg_list, u16 buf_size,
+		   struct ice_sq_cd *cd);
 
 bool ice_check_sq_alive(struct ice_hw *hw, struct ice_ctl_q_info *cq);
 enum ice_status ice_aq_q_shutdown(struct ice_hw *hw, bool unloading);
drivers/net/ice/base/ice_flex_pipe.c +1 -1
index 2d23c36eb..ff615f94f 100644
@@ -1314,7 +1314,7 @@ static void ice_init_pkg_regs(struct ice_hw *hw)
  * ice_copy_and_init_pkg() instead of directly calling ice_init_pkg() in this
  * case.
  */
-static enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
+enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
 {
 	struct ice_pkg_hdr *pkg;
 	enum ice_status status;
drivers/net/ice/base/ice_flex_pipe.h +2 -0
index 23fffed75..00c2b6682 100644
@@ -88,6 +88,8 @@ ice_set_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 cntxt);
 struct ice_prof_map *
 ice_get_prof_context(struct ice_hw *hw, enum ice_block blk, u64 id, u64 *cntxt);
 enum ice_status
+ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len);
+enum ice_status
 ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
 enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
 void ice_free_seg(struct ice_hw *hw);
drivers/net/ice/base/ice_switch.c +3 -3
index 512e64b91..e6fc9fcee 100644
@@ -288,7 +288,7 @@ enum ice_status ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id)
  *
  * Add a VSI context to the hardware (0x0210)
  */
-static enum ice_status
+enum ice_status
 ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 	       struct ice_sq_cd *cd)
 {
@@ -331,7 +331,7 @@ ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  *
  * Free VSI context info from hardware (0x0213)
  */
-static enum ice_status
+enum ice_status
 ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		bool keep_vsi_alloc, struct ice_sq_cd *cd)
 {
@@ -366,7 +366,7 @@ ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
  *
  * Update VSI context in the hardware (0x0211)
  */
-static enum ice_status
+enum ice_status
 ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
 		  struct ice_sq_cd *cd)
 {
drivers/net/ice/base/ice_switch.h +9 -0
index 90dfdabcb..b28e55a4f 100644
@@ -271,6 +271,15 @@ enum ice_promisc_flags {
 
 /* VSI related commands */
 enum ice_status
+ice_aq_add_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+	       struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_free_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		bool keep_vsi_alloc, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_update_vsi(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		  struct ice_sq_cd *cd);
+enum ice_status
 ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
 	    struct ice_sq_cd *cd);
 enum ice_status
Signature · 1 line
2.13.6
author
#53 lore raw

PATCH v2 8/37 net/ice/base: add more APIs in switch module

In reply to Qi Zhang

Add below APIs in switch module

1. ice_aq_get_vsi_params - get VSI context info
2. ice_aq_add_update_mir_rule - add/update mirror rule
3. ice_aq_delete_mir_rule - delete mirror rule
4. ice_aq_set_storm_ctrl - set storm control configuration
5. ice_aq_get_storm_ctrl - get storm control configuration

PMD can use these APIs to enable mirror rule and storm control related features.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 136 ++++++++++++++++++++
 drivers/net/ice/base/ice_switch.c     | 228 ++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h     |  29 +++++
 3 files changed, 393 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +136 -0
index 056a9fbef..724657af6 100644
@@ -177,6 +177,13 @@ struct ice_aqc_clear_pxe {
 };
 
 
+/* Configure No-Drop Policy Command (direct 0x0112) */
+struct ice_aqc_config_no_drop_policy {
+	u8 opts;
+#define ICE_AQC_FORCE_NO_DROP			BIT(0)
+	u8 rsvd[15];
+};
+
 /* Get switch configuration (0x0200) */
 struct ice_aqc_get_sw_cfg {
 	/* Reserved for command and copy of request flags for response */
@@ -350,6 +357,19 @@ struct ice_aqc_add_update_free_vsi_resp {
 };
 
 
+struct ice_aqc_get_vsi_resp {
+	__le16 vsi_num;
+	u8 vf_id;
+	/* The vsi_flags field uses the ICE_AQ_VSI_TYPE_* defines for values.
+	 * These are found above in struct ice_aqc_add_get_update_free_vsi.
+	 */
+	u8 vsi_flags;
+	__le16 vsi_used;
+	__le16 vsi_free;
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
 
 struct ice_aqc_vsi_props {
 	__le16 valid_sections;
@@ -506,6 +526,110 @@ struct ice_aqc_vsi_props {
 };
 
 
+/* Add/update mirror rule - direct (0x0260) */
+#define ICE_AQC_RULE_ID_VALID_S		7
+#define ICE_AQC_RULE_ID_VALID_M		(0x1 << ICE_AQC_RULE_ID_VALID_S)
+#define ICE_AQC_RULE_ID_S		0
+#define ICE_AQC_RULE_ID_M		(0x3F << ICE_AQC_RULE_ID_S)
+
+/* Following defines to be used while processing caller specified mirror list
+ * of VSI indexes.
+ */
+/* Action: Byte.bit (1.7)
+ *	0 = Remove VSI from mirror rule
+ *	1 = Add VSI to mirror rule
+ */
+#define ICE_AQC_RULE_ACT_S	15
+#define ICE_AQC_RULE_ACT_M	(0x1 << ICE_AQC_RULE_ACT_S)
+/* Action: 1.2:0.0 = Mirrored VSI */
+#define ICE_AQC_RULE_MIRRORED_VSI_S	0
+#define ICE_AQC_RULE_MIRRORED_VSI_M	(0x7FF << ICE_AQC_RULE_MIRRORED_VSI_S)
+
+/* This is to be used by add/update mirror rule Admin Queue command.
+ * In case of add mirror rule - if rule ID is specified as
+ * INVAL_MIRROR_RULE_ID, new rule ID is allocated from shared pool.
+ * If specified rule_id is valid, then it is used. If specified rule_id
+ * is in use then new mirroring rule is added.
+ */
+#define ICE_INVAL_MIRROR_RULE_ID	0xFFFF
+
+struct ice_aqc_add_update_mir_rule {
+	__le16 rule_id;
+
+	__le16 rule_type;
+#define ICE_AQC_RULE_TYPE_S		0
+#define ICE_AQC_RULE_TYPE_M		(0x7 << ICE_AQC_RULE_TYPE_S)
+	/* VPORT ingress/egress */
+#define ICE_AQC_RULE_TYPE_VPORT_INGRESS	0x1
+#define ICE_AQC_RULE_TYPE_VPORT_EGRESS	0x2
+	/* Physical port ingress mirroring.
+	 * All traffic received by this port
+	 */
+#define ICE_AQC_RULE_TYPE_PPORT_INGRESS	0x6
+	/* Physical port egress mirroring. All traffic sent by this port */
+#define ICE_AQC_RULE_TYPE_PPORT_EGRESS	0x7
+
+	/* Number of mirrored entries.
+	 * The values are in the command buffer
+	 */
+	__le16 num_entries;
+
+	/* Destination VSI */
+	__le16 dest;
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
+/* Delete mirror rule - direct(0x0261) */
+struct ice_aqc_delete_mir_rule {
+	__le16 rule_id;
+	__le16 rsvd;
+
+	/* Byte.bit: 20.0 = Keep allocation. If set VSI stays part of
+	 * the PF allocated resources, otherwise it is returned to the
+	 * shared pool
+	 */
+#define ICE_AQC_FLAG_KEEP_ALLOCD_S	0
+#define ICE_AQC_FLAG_KEEP_ALLOCD_M	(0x1 << ICE_AQC_FLAG_KEEP_ALLOCD_S)
+	__le16 flags;
+
+	u8 reserved[10];
+};
+
+/* Set/Get storm config - (direct 0x0280, 0x0281) */
+/* This structure holds get storm configuration response and same structure
+ * is used to perform set_storm_cfg
+ */
+struct ice_aqc_storm_cfg {
+	__le32 bcast_thresh_size;
+	__le32 mcast_thresh_size;
+	/* Bit 18:0 - Traffic upper threshold size
+	 * Bit 31:19 - Reserved
+	 */
+#define ICE_AQ_THRESHOLD_S	0
+#define ICE_AQ_THRESHOLD_M	(0x7FFFF << ICE_AQ_THRESHOLD_S)
+
+	__le32 storm_ctrl_ctrl;
+	/* Bit 0: MDIPW - Drop Multicast packets in previous window
+	 * Bit 1: MDICW - Drop multicast packets in current window
+	 * Bit 2: BDIPW - Drop broadcast packets in previous window
+	 * Bit 3: BDICW - Drop broadcast packets in current window
+	 */
+#define ICE_AQ_STORM_CTRL_MDIPW_DROP_MULTICAST	BIT(0)
+#define ICE_AQ_STORM_CTRL_MDICW_DROP_MULTICAST	BIT(1)
+#define ICE_AQ_STORM_CTRL_BDIPW_DROP_MULTICAST	BIT(2)
+#define ICE_AQ_STORM_CTRL_BDICW_DROP_MULTICAST	BIT(3)
+	/* Bit 7:5 : Reserved */
+	/* Bit 27:8 : Interval - BSC/MSC Time-interval specification: The
+	 * interval size for applying ingress broadcast or multicast storm
+	 * control.
+	 */
+#define ICE_AQ_STORM_BSC_MSC_TIME_INTERVAL_S	8
+#define ICE_AQ_STORM_BSC_MSC_TIME_INTERVAL_M	\
+			(0xFFFFF << ICE_AQ_STORM_BSC_MSC_TIME_INTERVAL_S)
+	__le32 reserved;
+};
+
 
 #define ICE_MAX_NUM_RECIPES 64
 
@@ -1771,6 +1895,9 @@ struct ice_aq_desc {
 		struct ice_aqc_manage_mac_read mac_read;
 		struct ice_aqc_manage_mac_write mac_write;
 		struct ice_aqc_clear_pxe clear_pxe;
+		struct ice_aqc_config_no_drop_policy no_drop;
+		struct ice_aqc_add_update_mir_rule add_update_rule;
+		struct ice_aqc_delete_mir_rule del_rule;
 		struct ice_aqc_list_caps get_cap;
 		struct ice_aqc_get_phy_caps get_phy;
 		struct ice_aqc_set_phy_cfg set_phy;
@@ -1778,6 +1905,7 @@ struct ice_aq_desc {
 		struct ice_aqc_set_port_id_led set_port_id_led;
 		struct ice_aqc_get_sw_cfg get_sw_conf;
 		struct ice_aqc_sw_rules sw_rules;
+		struct ice_aqc_storm_cfg storm_conf;
 		struct ice_aqc_get_topo get_topo;
 		struct ice_aqc_sched_elem_cmd sched_elem_cmd;
 		struct ice_aqc_query_txsched_res query_sched_res;
@@ -1795,6 +1923,7 @@ struct ice_aq_desc {
 		struct ice_aqc_txqs_cleanup txqs_cleanup;
 		struct ice_aqc_add_get_update_free_vsi vsi_cmd;
 		struct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;
+		struct ice_aqc_get_vsi_resp get_vsi_resp;
 		struct ice_aqc_download_pkg download_pkg;
 		struct ice_aqc_get_pkg_info_list get_pkg_info_list;
 		struct ice_aqc_fw_logging fw_logging;
@@ -1912,6 +2041,13 @@ enum ice_adminq_opc {
 	ice_aqc_opc_get_vsi_params			= 0x0212,
 	ice_aqc_opc_free_vsi				= 0x0213,
 
+	/* Mirroring rules - add/update, delete */
+	ice_aqc_opc_add_update_mir_rule			= 0x0260,
+	ice_aqc_opc_del_mir_rule			= 0x0261,
+
+	/* storm configuration */
+	ice_aqc_opc_set_storm_cfg			= 0x0280,
+	ice_aqc_opc_get_storm_cfg			= 0x0281,
 
 
 	/* switch rules population commands */
drivers/net/ice/base/ice_switch.c +228 -0

241 lines not on this page · raw message

drivers/net/ice/base/ice_switch.h +29 -0
index b28e55a4f..ebcfaa120 100644
@@ -29,6 +29,19 @@ struct ice_vsi_ctx {
 	struct LIST_HEAD_TYPE rss_list_head;
 };
 
+/* This is to be used by add/update mirror rule Admin Queue command */
+struct ice_mir_rule_buf {
+	u16 vsi_idx; /* VSI index */
+
+	/* For each VSI, user can specify whether corresponding VSI
+	 * should be added/removed to/from mirror rule
+	 *
+	 * add mirror rule: this should always be TRUE.
+	 * update mirror rule:  add(true) or remove(false) VSI to/from
+	 * mirror rule
+	 */
+	u8 add;
+};
 
 /* Switch recipe ID enum values are specific to hardware */
 enum ice_sw_lkup_type {
@@ -290,6 +303,22 @@ ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
 	       struct ice_sq_cd *cd);
 struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
 void ice_clear_all_vsi_ctx(struct ice_hw *hw);
+enum ice_status
+ice_aq_get_vsi_params(struct ice_hw *hw, struct ice_vsi_ctx *vsi_ctx,
+		      struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_add_update_mir_rule(struct ice_hw *hw, u16 rule_type, u16 dest_vsi,
+			   u16 count, struct ice_mir_rule_buf *mr_buf,
+			   struct ice_sq_cd *cd, u16 *rule_id);
+enum ice_status
+ice_aq_delete_mir_rule(struct ice_hw *hw, u16 rule_id, bool keep_allocd,
+		       struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_get_storm_ctrl(struct ice_hw *hw, u32 *bcast_thresh, u32 *mcast_thresh,
+		      u32 *ctl_bitmask);
+enum ice_status
+ice_aq_set_storm_ctrl(struct ice_hw *hw, u32 bcast_thresh, u32 mcast_thresh,
+		      u32 ctl_bitmask);
 /* Switch config */
 enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
 
Signature · 1 line
2.13.6
author
#54 lore raw

PATCH v2 9/37 net/ice/base: add VSI queue context framework

In reply to Qi Zhang

Added code to allocate VSI queue contexts to save the queue specific information like bandwidth etc.

---
 drivers/net/ice/base/ice_sched.c  | 52 +++++++++++++++++++++++++++++++++++----
 drivers/net/ice/base/ice_switch.c | 26 ++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  8 ++++++
 3 files changed, 81 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_sched.c +47 -5
index 237bf7350..ab6097237 100644
@@ -576,6 +576,48 @@ ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids,
 }
 
 /**
+ * ice_alloc_lan_q_ctx - allocate LAN queue contexts for the given VSI and TC
+ * @hw: pointer to the HW struct
+ * @vsi_handle: VSI handle
+ * @tc: TC number
+ * @new_numqs: number of queues
+ */
+static enum ice_status
+ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs)
+{
+	struct ice_vsi_ctx *vsi_ctx;
+	struct ice_q_ctx *q_ctx;
+
+	vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
+	if (!vsi_ctx)
+		return ICE_ERR_PARAM;
+	/* allocate LAN queue contexts */
+	if (!vsi_ctx->lan_q_ctx[tc]) {
+		vsi_ctx->lan_q_ctx[tc] = (struct ice_q_ctx *)
+			ice_calloc(hw, new_numqs, sizeof(*q_ctx));
+		if (!vsi_ctx->lan_q_ctx[tc])
+			return ICE_ERR_NO_MEMORY;
+		vsi_ctx->num_lan_q_entries[tc] = new_numqs;
+		return ICE_SUCCESS;
+	}
+	/* num queues are increased, update the queue contexts */
+	if (new_numqs > vsi_ctx->num_lan_q_entries[tc]) {
+		u16 prev_num = vsi_ctx->num_lan_q_entries[tc];
+
+		q_ctx = (struct ice_q_ctx *)
+			ice_calloc(hw, new_numqs, sizeof(*q_ctx));
+		if (!q_ctx)
+			return ICE_ERR_NO_MEMORY;
+		ice_memcpy(q_ctx, vsi_ctx->lan_q_ctx[tc],
+			   prev_num * sizeof(*q_ctx), ICE_DMA_TO_NONDMA);
+		ice_free(hw, vsi_ctx->lan_q_ctx[tc]);
+		vsi_ctx->lan_q_ctx[tc] = q_ctx;
+		vsi_ctx->num_lan_q_entries[tc] = new_numqs;
+	}
+	return ICE_SUCCESS;
+}
+
+/**
  * ice_aq_rl_profile - performs a rate limiting task
  * @hw: pointer to the HW struct
  * @opcode:opcode for add, query, or remove profile(s)
@@ -1717,14 +1759,14 @@ ice_sched_update_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,
 	if (!vsi_ctx)
 		return ICE_ERR_PARAM;
 
-	if (owner == ICE_SCHED_NODE_OWNER_LAN)
-		prev_numqs = vsi_ctx->sched.max_lanq[tc];
-	else
-		return ICE_ERR_PARAM;
-
+	prev_numqs = vsi_ctx->sched.max_lanq[tc];
 	/* num queues are not changed or less than the previous number */
 	if (new_numqs <= prev_numqs)
 		return status;
+	status = ice_alloc_lan_q_ctx(hw, vsi_handle, tc, new_numqs);
+	if (status)
+		return status;
+
 	if (new_numqs)
 		ice_sched_calc_vsi_child_nodes(hw, new_numqs, new_num_nodes);
 	/* Keep the max number of queue configuration all the time. Update the
drivers/net/ice/base/ice_switch.c +26 -0
index 34637c1be..4b53636b4 100644
@@ -3,6 +3,8 @@
  */
 
 #include "ice_switch.h"
+#include "ice_flex_type.h"
+#include "ice_flow.h"
 
 
 #define ICE_ETH_DA_OFFSET		0
@@ -447,6 +449,27 @@ ice_save_vsi_ctx(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi)
 }
 
 /**
+ * ice_clear_vsi_q_ctx - clear VSI queue contexts for all TCs
+ * @hw: pointer to the HW struct
+ * @vsi_handle: VSI handle
+ */
+static void ice_clear_vsi_q_ctx(struct ice_hw *hw, u16 vsi_handle)
+{
+	struct ice_vsi_ctx *vsi;
+	u8 i;
+
+	vsi = ice_get_vsi_ctx(hw, vsi_handle);
+	if (!vsi)
+		return;
+	ice_for_each_traffic_class(i) {
+		if (vsi->lan_q_ctx[i]) {
+			ice_free(hw, vsi->lan_q_ctx[i]);
+			vsi->lan_q_ctx[i] = NULL;
+		}
+	}
+}
+
+/**
  * ice_clear_vsi_ctx - clear the VSI context entry
  * @hw: pointer to the HW struct
  * @vsi_handle: VSI handle
@@ -459,6 +482,9 @@ static void ice_clear_vsi_ctx(struct ice_hw *hw, u16 vsi_handle)
 
 	vsi = ice_get_vsi_ctx(hw, vsi_handle);
 	if (vsi) {
+		if (!LIST_EMPTY(&vsi->rss_list_head))
+			ice_rem_all_rss_vsi_ctx(hw, vsi_handle);
+		ice_clear_vsi_q_ctx(hw, vsi_handle);
 		ice_destroy_lock(&vsi->rss_locks);
 		ice_free(hw, vsi);
 		hw->vsi_ctx[vsi_handle] = NULL;
drivers/net/ice/base/ice_switch.h +8 -0
index ebcfaa120..c6d31475c 100644
@@ -15,6 +15,12 @@
 
 
 #define ICE_VSI_INVAL_ID 0xFFFF
+#define ICE_INVAL_Q_HANDLE 0xFFFF
+
+/* VSI queue context structure */
+struct ice_q_ctx {
+	u16  q_handle;
+};
 
 /* VSI context structure for add/get/update/free operations */
 struct ice_vsi_ctx {
@@ -25,6 +31,8 @@ struct ice_vsi_ctx {
 	struct ice_aqc_vsi_props info;
 	struct ice_sched_vsi_info sched;
 	u8 alloc_from_pool;
+	u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
+	struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
 	struct ice_lock rss_locks;	/* protect rss config in VSI ctx */
 	struct LIST_HEAD_TYPE rss_list_head;
 };
Signature · 1 line
2.13.6
author
#55 lore raw

PATCH v2 10/37 net/ice/base: add APIs to add remove ethertype filter

In reply to Qi Zhang

Add API ice_remove_eth_mac and ice_add_eth_mac to support adding / removing ethertype (or MAC) based filter rules.

PMD driver can use these APIs to enable related rte_flow rule.

---
 drivers/net/ice/base/ice_switch.c | 57 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  4 +++
 2 files changed, 61 insertions(+)
drivers/net/ice/base/ice_switch.c +57 -0
index 4b53636b4..4af6a323c 100644
@@ -2415,6 +2415,63 @@ ice_add_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *mv_list)
 }
 #endif
 
+/**
+ * ice_add_eth_mac - Add ethertype and MAC based filter rule
+ * @hw: pointer to the hardware structure
+ * @em_list: list of ether type MAC filter, MAC is optional
+ */
+enum ice_status
+ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list)
+{
+	struct ice_fltr_list_entry *em_list_itr;
+
+	LIST_FOR_EACH_ENTRY(em_list_itr, em_list, ice_fltr_list_entry,
+			    list_entry) {
+		enum ice_sw_lkup_type l_type =
+			em_list_itr->fltr_info.lkup_type;
+
+		if (l_type != ICE_SW_LKUP_ETHERTYPE_MAC &&
+		    l_type != ICE_SW_LKUP_ETHERTYPE)
+			return ICE_ERR_PARAM;
+
+		em_list_itr->fltr_info.flag = ICE_FLTR_TX;
+		em_list_itr->status = ice_add_rule_internal(hw, l_type,
+							    em_list_itr);
+		if (em_list_itr->status)
+			return em_list_itr->status;
+	}
+	return ICE_SUCCESS;
+}
+
+/**
+ * ice_remove_eth_mac - Remove an ethertype (or MAC) based filter rule
+ * @hw: pointer to the hardware structure
+ * @em_list: list of ethertype or ethertype MAC entries
+ */
+enum ice_status
+ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list)
+{
+	struct ice_fltr_list_entry *em_list_itr, *tmp;
+
+	if (!em_list || !hw)
+		return ICE_ERR_PARAM;
+
+	LIST_FOR_EACH_ENTRY_SAFE(em_list_itr, tmp, em_list, ice_fltr_list_entry,
+				 list_entry) {
+		enum ice_sw_lkup_type l_type =
+			em_list_itr->fltr_info.lkup_type;
+
+		if (l_type != ICE_SW_LKUP_ETHERTYPE_MAC &&
+		    l_type != ICE_SW_LKUP_ETHERTYPE)
+			return ICE_ERR_PARAM;
+
+		em_list_itr->status = ice_remove_rule_internal(hw, l_type,
+							       em_list_itr);
+		if (em_list_itr->status)
+			return em_list_itr->status;
+	}
+	return ICE_SUCCESS;
+}
 
 
 /**
drivers/net/ice/base/ice_switch.h +4 -0
index c6d31475c..f331621e1 100644
@@ -347,6 +347,10 @@ ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status
+ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
+enum ice_status
+ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
+enum ice_status
 ice_remove_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
 #ifndef NO_MACVLAN_SUPPORT
 enum ice_status
Signature · 1 line
2.13.6
author
#56 lore raw

PATCH v2 11/37 net/ice/base: add APIs to get allocated resources

In reply to Qi Zhang

1. ice_aq_get_res_alloc - get allocated resources.
2. ice_aq_get_res_descs - get allocated resource descriptors.

These APIs may help to PMD to enable some debug utilities to dump the resource allocation status.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 53 +++++++++++++++++++++-
 drivers/net/ice/base/ice_switch.c     | 83 +++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h     | 12 +++++
 3 files changed, 147 insertions(+), 1 deletion(-)
drivers/net/ice/base/ice_adminq_cmd.h +52 -1
index 724657af6..ca3d40c8b 100644
@@ -281,6 +281,34 @@ struct ice_aqc_get_sw_cfg_resp {
 
 #define ICE_AQC_RES_TYPE_FLAG_DEDICATED			0x00
 
+#define ICE_AQC_RES_TYPE_S	0
+#define ICE_AQC_RES_TYPE_M	(0x07F << ICE_AQC_RES_TYPE_S)
+
+/* Get Resource Allocation command (indirect 0x0204) */
+struct ice_aqc_get_res_alloc {
+	__le16 resp_elem_num; /* Used in response, reserved in command */
+	u8 reserved[6];
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
+/* Get Resource Allocation Response Buffer per response */
+struct ice_aqc_get_res_resp_elem {
+	__le16 res_type; /* Types defined above cmd 0x0204 */
+	__le16 total_capacity; /* Resources available to all PF's */
+	__le16 total_function; /* Resources allocated for a PF */
+	__le16 total_shared; /* Resources allocated as shared */
+	__le16 total_free; /* Resources un-allocated/not reserved by any PF */
+};
+
+/* Buffer for Get Resource command */
+struct ice_aqc_get_res_resp {
+	/* Number of resource entries to be calculated using
+	 * datalen/sizeof(struct ice_aqc_cmd_resp)).
+	 * Value of 'datalen' gets updated as part of response.
+	 */
+	struct ice_aqc_get_res_resp_elem elem[1];
+};
 
 
 /* Allocate Resources command (indirect 0x0208)
@@ -314,6 +342,28 @@ struct ice_aqc_alloc_free_res_elem {
 };
 
 
+/* Get Allocated Resource Descriptors Command (indirect 0x020A) */
+struct ice_aqc_get_allocd_res_desc {
+	union {
+		struct {
+			__le16 res; /* Types defined above cmd 0x0204 */
+			__le16 first_desc;
+			__le32 reserved;
+		} cmd;
+		struct {
+			__le16 res;
+			__le16 next_desc;
+			__le16 num_desc;
+			__le16 reserved;
+		} resp;
+	} ops;
+	__le32 addr_high;
+	__le32 addr_low;
+};
+
+struct ice_aqc_get_allocd_res_desc_resp {
+	struct ice_aqc_res_elem elem[1];
+};
 
 
 /* Add VSI (indirect 0x0210)
@@ -1912,7 +1962,6 @@ struct ice_aq_desc {
 		struct ice_aqc_query_node_to_root query_node_to_root;
 		struct ice_aqc_cfg_l2_node_cgd cfg_l2_node_cgd;
 		struct ice_aqc_rl_profile rl_profile;
-
 		struct ice_aqc_nvm nvm;
 		struct ice_aqc_nvm_cfg nvm_cfg;
 		struct ice_aqc_nvm_checksum nvm_checksum;
@@ -1930,6 +1979,8 @@ struct ice_aq_desc {
 		struct ice_aqc_get_clear_fw_log get_clear_fw_log;
 		struct ice_aqc_set_mac_lb set_mac_lb;
 		struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
+		struct ice_aqc_get_res_alloc get_res;
+		struct ice_aqc_get_allocd_res_desc get_res_desc;
 		struct ice_aqc_set_mac_cfg set_mac_cfg;
 		struct ice_aqc_set_event_mask set_event_mask;
 		struct ice_aqc_get_link_status get_link_status;
drivers/net/ice/base/ice_switch.c +83 -0

89 lines not on this page · raw message

drivers/net/ice/base/ice_switch.h +12 -0
index f331621e1..4b77d920f 100644
@@ -13,6 +13,10 @@
 #define ICE_DFLT_VSI_INVAL 0xff
 
 
+/* Worst case buffer length for ice_aqc_opc_get_res_alloc */
+#define ICE_MAX_RES_TYPES 0x80
+#define ICE_AQ_GET_RES_ALLOC_BUF_LEN \
+	(ICE_MAX_RES_TYPES * sizeof(struct ice_aqc_get_res_resp_elem))
 
 #define ICE_VSI_INVAL_ID 0xFFFF
 #define ICE_INVAL_Q_HANDLE 0xFFFF
@@ -343,6 +347,14 @@ ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
 enum ice_status
 ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id);
 enum ice_status
+ice_aq_get_res_alloc(struct ice_hw *hw, u16 *num_entries, void *buf,
+		     u16 buf_size, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_get_res_descs(struct ice_hw *hw, u16 num_entries,
+		     struct ice_aqc_get_allocd_res_desc_resp *buf,
+		     u16 buf_size, u16 res_type, bool res_shared, u16 *desc_id,
+		     struct ice_sq_cd *cd);
+enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
Signature · 1 line
2.13.6
author
#57 lore raw

PATCH v2 12/37 net/ice/base: add APIs to alloc/free resource counter

In reply to Qi Zhang

1. ice_alloc_res_cntr - allocate resource counter
2. ice_free_res_cntr - free resource counter
3. ice_alloc_vlan_res_counter - allocate vlan resource counter
4. ice_free_vlan_res_counter - free vlan resource counter

These APIs will be used when try to count the number of a flow be hitted.

---
 drivers/net/ice/base/ice_switch.c | 97 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  6 +++
 2 files changed, 103 insertions(+)
drivers/net/ice/base/ice_switch.c +97 -0
index c985c1e31..26fc0b46b 100644
@@ -3238,9 +3238,106 @@ void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle)
 	ice_remove_vsi_lkup_fltr(hw, vsi_handle, ICE_SW_LKUP_PROMISC_VLAN);
 }
 
+/**
+ * ice_alloc_res_cntr - allocating resource counter
+ * @hw: pointer to the hardware structure
+ * @type: type of resource
+ * @alloc_shared: if set it is shared else dedicated
+ * @num_items: number of entries requested for FD resource type
+ * @counter_id: counter index returned by AQ call
+ */
+enum ice_status
+ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		   u16 *counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *buf;
+	enum ice_status status;
+	u16 buf_len;
+
+	/* Allocate resource */
+	buf_len = sizeof(*buf);
+	buf = (struct ice_aqc_alloc_free_res_elem *)
+		ice_malloc(hw, buf_len);
+	if (!buf)
+		return ICE_ERR_NO_MEMORY;
+
+	buf->num_elems = CPU_TO_LE16(num_items);
+	buf->res_type = CPU_TO_LE16(((type << ICE_AQC_RES_TYPE_S) &
+				      ICE_AQC_RES_TYPE_M) | alloc_shared);
+
+	status = ice_aq_alloc_free_res(hw, 1, buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+	if (status)
+		goto exit;
+
+	*counter_id = LE16_TO_CPU(buf->elem[0].e.sw_resp);
+
+exit:
+	ice_free(hw, buf);
+	return status;
+}
+
+/**
+ * ice_free_res_cntr - free resource counter
+ * @hw: pointer to the hardware structure
+ * @type: type of resource
+ * @alloc_shared: if set it is shared else dedicated
+ * @num_items: number of entries to be freed for FD resource type
+ * @counter_id: counter ID resource which needs to be freed
+ */
+enum ice_status
+ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		  u16 counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *buf;
+	enum ice_status status;
+	u16 buf_len;
 
+	/* Free resource */
+	buf_len = sizeof(*buf);
+	buf = (struct ice_aqc_alloc_free_res_elem *)
+		ice_malloc(hw, buf_len);
+	if (!buf)
+		return ICE_ERR_NO_MEMORY;
 
+	buf->num_elems = CPU_TO_LE16(num_items);
+	buf->res_type = CPU_TO_LE16(((type << ICE_AQC_RES_TYPE_S) &
+				      ICE_AQC_RES_TYPE_M) | alloc_shared);
+	buf->elem[0].e.sw_resp = CPU_TO_LE16(counter_id);
 
+	status = ice_aq_alloc_free_res(hw, 1, buf, buf_len,
+				       ice_aqc_opc_free_res, NULL);
+	if (status)
+		ice_debug(hw, ICE_DBG_SW,
+			  "counter resource could not be freed\n");
+
+	ice_free(hw, buf);
+	return status;
+}
+
+/**
+ * ice_alloc_vlan_res_counter - obtain counter resource for VLAN type
+ * @hw: pointer to the hardware structure
+ * @counter_id: returns counter index
+ */
+enum ice_status ice_alloc_vlan_res_counter(struct ice_hw *hw, u16 *counter_id)
+{
+	return ice_alloc_res_cntr(hw, ICE_AQC_RES_TYPE_VLAN_COUNTER,
+				  ICE_AQC_RES_TYPE_FLAG_DEDICATED, 1,
+				  counter_id);
+}
+
+/**
+ * ice_free_vlan_res_counter - Free counter resource for VLAN type
+ * @hw: pointer to the hardware structure
+ * @counter_id: counter index to be freed
+ */
+enum ice_status ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id)
+{
+	return ice_free_res_cntr(hw, ICE_AQC_RES_TYPE_VLAN_COUNTER,
+				 ICE_AQC_RES_TYPE_FLAG_DEDICATED, 1,
+				 counter_id);
+}
 
 /**
  * ice_replay_vsi_fltr - Replay filters for requested VSI
drivers/net/ice/base/ice_switch.h +6 -0
index 4b77d920f..364083eb4 100644
@@ -338,6 +338,12 @@ enum ice_status
 ice_alloc_vlan_res_counter(struct ice_hw *hw, u16 *counter_id);
 enum ice_status
 ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
+enum ice_status
+ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		   u16 *counter_id);
+enum ice_status
+ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
+		  u16 counter_id);
 
 /* Switch/bridge related commands */
 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
Signature · 1 line
2.13.6
author
#58 lore raw

PATCH v2 13/37 net/ice/base: add APIs to get VSI promiscuous mode

In reply to Qi Zhang

1. ice_get_vsi_promisc - get promiscuous mode of give VSI.
2. ice_get_vsi_vlan_promisc - get VLAN promiscuous mode of given VSI.

PMD may use these APIs to check the real HW status, but not rely on a software flag when something abnormal.

---
 drivers/net/ice/base/ice_switch.c | 79 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |  7 ++++
 2 files changed, 86 insertions(+)
drivers/net/ice/base/ice_switch.c +79 -0
index 26fc0b46b..e4024a0b0 100644
@@ -2894,6 +2894,85 @@ static u8 ice_determine_promisc_mask(struct ice_fltr_info *fi)
 	return promisc_mask;
 }
 
+/**
+ * ice_get_vsi_promisc - get promiscuous mode of given VSI
+ * @hw: pointer to the hardware structure
+ * @vsi_handle: VSI handle to retrieve info from
+ * @promisc_mask: pointer to mask to be filled in
+ * @vid: VLAN ID of promisc VLAN VSI
+ */
+enum ice_status
+ice_get_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+		    u16 *vid)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *itr;
+	struct LIST_HEAD_TYPE *rule_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+
+	if (!ice_is_vsi_valid(hw, vsi_handle))
+		return ICE_ERR_PARAM;
+
+	*vid = 0;
+	*promisc_mask = 0;
+	rule_head = &sw->recp_list[ICE_SW_LKUP_PROMISC].filt_rules;
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_PROMISC].filt_rule_lock;
+
+	ice_acquire_lock(rule_lock);
+	LIST_FOR_EACH_ENTRY(itr, rule_head,
+			    ice_fltr_mgmt_list_entry, list_entry) {
+		/* Continue if this filter doesn't apply to this VSI or the
+		 * VSI ID is not in the VSI map for this filter
+		 */
+		if (!ice_vsi_uses_fltr(itr, vsi_handle))
+			continue;
+
+		*promisc_mask |= ice_determine_promisc_mask(&itr->fltr_info);
+	}
+	ice_release_lock(rule_lock);
+
+	return ICE_SUCCESS;
+}
+
+/**
+ * ice_get_vsi_vlan_promisc - get VLAN promiscuous mode of given VSI
+ * @hw: pointer to the hardware structure
+ * @vsi_handle: VSI handle to retrieve info from
+ * @promisc_mask: pointer to mask to be filled in
+ * @vid: VLAN ID of promisc VLAN VSI
+ */
+enum ice_status
+ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+			 u16 *vid)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *itr;
+	struct LIST_HEAD_TYPE *rule_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+
+	if (!ice_is_vsi_valid(hw, vsi_handle))
+		return ICE_ERR_PARAM;
+
+	*vid = 0;
+	*promisc_mask = 0;
+	rule_head = &sw->recp_list[ICE_SW_LKUP_PROMISC_VLAN].filt_rules;
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_PROMISC_VLAN].filt_rule_lock;
+
+	ice_acquire_lock(rule_lock);
+	LIST_FOR_EACH_ENTRY(itr, rule_head, ice_fltr_mgmt_list_entry,
+			    list_entry) {
+		/* Continue if this filter doesn't apply to this VSI or the
+		 * VSI ID is not in the VSI map for this filter
+		 */
+		if (!ice_vsi_uses_fltr(itr, vsi_handle))
+			continue;
+
+		*promisc_mask |= ice_determine_promisc_mask(&itr->fltr_info);
+	}
+	ice_release_lock(rule_lock);
+
+	return ICE_SUCCESS;
+}
 
 /**
  * ice_remove_promisc - Remove promisc based filter rules
drivers/net/ice/base/ice_switch.h +7 -0
index 364083eb4..0d70b38f4 100644
@@ -394,6 +394,13 @@ enum ice_status
 ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
 			 bool rm_vlan_promisc);
 
+/* Get VSIs Promisc/defport settings */
+enum ice_status
+ice_get_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+		    u16 *vid);
+enum ice_status
+ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
+			 u16 *vid);
 
 
 
Signature · 1 line
2.13.6
author
#59 lore raw

PATCH v2 14/37 net/ice/base: add MAC filter with marker and counter

In reply to Qi Zhang

1. ice_add_mac_with_sw_marker - add filter with software marker.
2. ice_add_mac_with_counter - add filter with counter enabled.

---
 drivers/net/ice/base/ice_switch.c | 328 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   5 +
 2 files changed, 333 insertions(+)
drivers/net/ice/base/ice_switch.c +328 -0
index e4024a0b0..bfcb33ea6 100644
@@ -1338,6 +1338,95 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
 	return status;
 }
 
+/**
+ * ice_add_counter_act - add/update filter rule with counter action
+ * @hw: pointer to the hardware structure
+ * @m_ent: the management entry for which counter needs to be added
+ * @counter_id: VLAN counter ID returned as part of allocate resource
+ * @l_id: large action resource ID
+ */
+static enum ice_status
+ice_add_counter_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
+		    u16 counter_id, u16 l_id)
+{
+	struct ice_aqc_sw_rules_elem *lg_act;
+	struct ice_aqc_sw_rules_elem *rx_tx;
+	enum ice_status status;
+	/* 2 actions will be added while adding a large action counter */
+	const int num_acts = 2;
+	u16 lg_act_size;
+	u16 rules_size;
+	u16 f_rule_id;
+	u32 act;
+	u16 id;
+
+	if (m_ent->fltr_info.lkup_type != ICE_SW_LKUP_MAC)
+		return ICE_ERR_PARAM;
+
+	/* Create two back-to-back switch rules and submit them to the HW using
+	 * one memory buffer:
+	 * 1. Large Action
+	 * 2. Look up Tx Rx
+	 */
+	lg_act_size = (u16)ICE_SW_RULE_LG_ACT_SIZE(num_acts);
+	rules_size = lg_act_size + ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
+	lg_act = (struct ice_aqc_sw_rules_elem *)ice_malloc(hw,
+								 rules_size);
+	if (!lg_act)
+		return ICE_ERR_NO_MEMORY;
+
+	rx_tx = (struct ice_aqc_sw_rules_elem *)
+		((u8 *)lg_act + lg_act_size);
+
+	/* Fill in the first switch rule i.e. large action */
+	lg_act->type = CPU_TO_LE16(ICE_AQC_SW_RULES_T_LG_ACT);
+	lg_act->pdata.lg_act.index = CPU_TO_LE16(l_id);
+	lg_act->pdata.lg_act.size = CPU_TO_LE16(num_acts);
+
+	/* First action VSI forwarding or VSI list forwarding depending on how
+	 * many VSIs
+	 */
+	id = (m_ent->vsi_count > 1) ?  m_ent->fltr_info.fwd_id.vsi_list_id :
+		m_ent->fltr_info.fwd_id.hw_vsi_id;
+
+	act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;
+	act |= (id << ICE_LG_ACT_VSI_LIST_ID_S) &
+		ICE_LG_ACT_VSI_LIST_ID_M;
+	if (m_ent->vsi_count > 1)
+		act |= ICE_LG_ACT_VSI_LIST;
+	lg_act->pdata.lg_act.act[0] = CPU_TO_LE32(act);
+
+	/* Second action counter ID */
+	act = ICE_LG_ACT_STAT_COUNT;
+	act |= (counter_id << ICE_LG_ACT_STAT_COUNT_S) &
+		ICE_LG_ACT_STAT_COUNT_M;
+	lg_act->pdata.lg_act.act[1] = CPU_TO_LE32(act);
+
+	/* call the fill switch rule to fill the lookup Tx Rx structure */
+	ice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx,
+			 ice_aqc_opc_update_sw_rules);
+
+	act = ICE_SINGLE_ACT_PTR;
+	act |= (l_id << ICE_SINGLE_ACT_PTR_VAL_S) & ICE_SINGLE_ACT_PTR_VAL_M;
+	rx_tx->pdata.lkup_tx_rx.act = CPU_TO_LE32(act);
+
+	/* Use the filter rule ID of the previously created rule with single
+	 * act. Once the update happens, hardware will treat this as large
+	 * action
+	 */
+	f_rule_id = m_ent->fltr_info.fltr_rule_id;
+	rx_tx->pdata.lkup_tx_rx.index = CPU_TO_LE16(f_rule_id);
+
+	status = ice_aq_sw_rules(hw, lg_act, rules_size, 2,
+				 ice_aqc_opc_update_sw_rules, NULL);
+	if (!status) {
+		m_ent->lg_act_idx = l_id;
+		m_ent->counter_index = counter_id;
+	}
+
+	ice_free(hw, lg_act);
+	return status;
+}
 
 /**
  * ice_create_vsi_list_map
@@ -3419,6 +3508,245 @@ enum ice_status ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id)
 }
 
 /**
+ * ice_alloc_res_lg_act - add large action resource
+ * @hw: pointer to the hardware structure
+ * @l_id: large action ID to fill it in
+ * @num_acts: number of actions to hold with a large action entry
+ */
+static enum ice_status
+ice_alloc_res_lg_act(struct ice_hw *hw, u16 *l_id, u16 num_acts)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf;
+	enum ice_status status;
+	u16 buf_len;
+
+	if (num_acts > ICE_MAX_LG_ACT || num_acts == 0)
+		return ICE_ERR_PARAM;
+
+	/* Allocate resource for large action */
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	sw_buf->num_elems = CPU_TO_LE16(1);
+
+	/* If num_acts is 1, use ICE_AQC_RES_TYPE_WIDE_TABLE_1.
+	 * If num_acts is 2, use ICE_AQC_RES_TYPE_WIDE_TABLE_3.
+	 * If num_acts is greater than 2, then use
+	 * ICE_AQC_RES_TYPE_WIDE_TABLE_4.
+	 * The num_acts cannot exceed 4. This was ensured at the
+	 * beginning of the function.
+	 */
+	if (num_acts == 1)
+		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_1);
+	else if (num_acts == 2)
+		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_2);
+	else
+		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_4);
+
+	status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+	if (!status)
+		*l_id = LE16_TO_CPU(sw_buf->elem[0].e.sw_resp);
+
+	ice_free(hw, sw_buf);
+	return status;
+}
+
+/**
+ * ice_add_mac_with_sw_marker - add filter with sw marker
+ * @hw: pointer to the hardware structure
+ * @f_info: filter info structure containing the MAC filter information
+ * @sw_marker: sw marker to tag the Rx descriptor with
+ */
+enum ice_status
+ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,
+			   u16 sw_marker)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *m_entry;
+	struct ice_fltr_list_entry fl_info;
+	struct LIST_HEAD_TYPE l_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+	enum ice_status ret;
+	bool entry_exists;
+	u16 lg_act_id;
+
+	if (f_info->fltr_act != ICE_FWD_TO_VSI)
+		return ICE_ERR_PARAM;
+
+	if (f_info->lkup_type != ICE_SW_LKUP_MAC)
+		return ICE_ERR_PARAM;
+
+	if (sw_marker == ICE_INVAL_SW_MARKER_ID)
+		return ICE_ERR_PARAM;
+
+	if (!ice_is_vsi_valid(hw, f_info->vsi_handle))
+		return ICE_ERR_PARAM;
+	f_info->fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, f_info->vsi_handle);
+
+	/* Add filter if it doesn't exist so then the adding of large
+	 * action always results in update
+	 */
+
+	INIT_LIST_HEAD(&l_head);
+	fl_info.fltr_info = *f_info;
+	LIST_ADD(&fl_info.list_entry, &l_head);
+
+	entry_exists = false;
+	ret = ice_add_mac(hw, &l_head);
+	if (ret == ICE_ERR_ALREADY_EXISTS)
+		entry_exists = true;
+	else if (ret)
+		return ret;
+
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
+	ice_acquire_lock(rule_lock);
+	/* Get the book keeping entry for the filter */
+	m_entry = ice_find_rule_entry(hw, ICE_SW_LKUP_MAC, f_info);
+	if (!m_entry)
+		goto exit_error;
+
+	/* If counter action was enabled for this rule then don't enable
+	 * sw marker large action
+	 */
+	if (m_entry->counter_index != ICE_INVAL_COUNTER_ID) {
+		ret = ICE_ERR_PARAM;
+		goto exit_error;
+	}
+
+	/* if same marker was added before */
+	if (m_entry->sw_marker_id == sw_marker) {
+		ret = ICE_ERR_ALREADY_EXISTS;
+		goto exit_error;
+	}
+
+	/* Allocate a hardware table entry to hold large act. Three actions
+	 * for marker based large action
+	 */
+	ret = ice_alloc_res_lg_act(hw, &lg_act_id, 3);
+	if (ret)
+		goto exit_error;
+
+	if (lg_act_id == ICE_INVAL_LG_ACT_INDEX)
+		goto exit_error;
+
+	/* Update the switch rule to add the marker action */
+	ret = ice_add_marker_act(hw, m_entry, sw_marker, lg_act_id);
+	if (!ret) {
+		ice_release_lock(rule_lock);
+		return ret;
+	}
+
+exit_error:
+	ice_release_lock(rule_lock);
+	/* only remove entry if it did not exist previously */
+	if (!entry_exists)
+		ret = ice_remove_mac(hw, &l_head);
+
+	return ret;
+}
+
+/**
+ * ice_add_mac_with_counter - add filter with counter enabled
+ * @hw: pointer to the hardware structure
+ * @f_info: pointer to filter info structure containing the MAC filter
+ *          information
+ */
+enum ice_status
+ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	struct ice_fltr_mgmt_list_entry *m_entry;
+	struct ice_fltr_list_entry fl_info;
+	struct LIST_HEAD_TYPE l_head;
+	struct ice_lock *rule_lock;	/* Lock to protect filter rule list */
+	enum ice_status ret;
+	bool entry_exist;
+	u16 counter_id;
+	u16 lg_act_id;
+
+	if (f_info->fltr_act != ICE_FWD_TO_VSI)
+		return ICE_ERR_PARAM;
+
+	if (f_info->lkup_type != ICE_SW_LKUP_MAC)
+		return ICE_ERR_PARAM;
+
+	if (!ice_is_vsi_valid(hw, f_info->vsi_handle))
+		return ICE_ERR_PARAM;
+	f_info->fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, f_info->vsi_handle);
+
+	entry_exist = false;
+
+	rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
+
+	/* Add filter if it doesn't exist so then the adding of large
+	 * action always results in update
+	 */
+	INIT_LIST_HEAD(&l_head);
+
+	fl_info.fltr_info = *f_info;
+	LIST_ADD(&fl_info.list_entry, &l_head);
+
+	ret = ice_add_mac(hw, &l_head);
+	if (ret == ICE_ERR_ALREADY_EXISTS)
+		entry_exist = true;
+	else if (ret)
+		return ret;
+
+	ice_acquire_lock(rule_lock);
+	m_entry = ice_find_rule_entry(hw, ICE_SW_LKUP_MAC, f_info);
+	if (!m_entry) {
+		ret = ICE_ERR_BAD_PTR;
+		goto exit_error;
+	}
+
+	/* Don't enable counter for a filter for which sw marker was enabled */
+	if (m_entry->sw_marker_id != ICE_INVAL_SW_MARKER_ID) {
+		ret = ICE_ERR_PARAM;
+		goto exit_error;
+	}
+
+	/* If a counter was already enabled then don't need to add again */
+	if (m_entry->counter_index != ICE_INVAL_COUNTER_ID) {
+		ret = ICE_ERR_ALREADY_EXISTS;
+		goto exit_error;
+	}
+
+	/* Allocate a hardware table entry to VLAN counter */
+	ret = ice_alloc_vlan_res_counter(hw, &counter_id);
+	if (ret)
+		goto exit_error;
+
+	/* Allocate a hardware table entry to hold large act. Two actions for
+	 * counter based large action
+	 */
+	ret = ice_alloc_res_lg_act(hw, &lg_act_id, 2);
+	if (ret)
+		goto exit_error;
+
+	if (lg_act_id == ICE_INVAL_LG_ACT_INDEX)
+		goto exit_error;
+
+	/* Update the switch rule to add the counter action */
+	ret = ice_add_counter_act(hw, m_entry, counter_id, lg_act_id);
+	if (!ret) {
+		ice_release_lock(rule_lock);
+		return ret;
+	}
+
+exit_error:
+	ice_release_lock(rule_lock);
+	/* only remove entry if it did not exist previously */
+	if (!entry_exist)
+		ret = ice_remove_mac(hw, &l_head);
+
+	return ret;
+}
+
+/**
  * ice_replay_vsi_fltr - Replay filters for requested VSI
  * @hw: pointer to the hardware structure
  * @vsi_handle: driver VSI handle
drivers/net/ice/base/ice_switch.h +5 -0
index 0d70b38f4..b396a486c 100644
@@ -377,6 +377,11 @@ enum ice_status
 ice_remove_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
 #endif /* !NO_MACVLAN_SUPPORT */
 
+enum ice_status
+ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,
+			   u16 sw_marker);
+enum ice_status
+ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info);
 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
 
 
Signature · 1 line
2.13.6
author
#60 lore raw

PATCH v2 15/37 net/ice/base: add two helper functions for flow management

In reply to Qi Zhang

1. ice_rem_all_sw_rules_info - remove all switch rules.
2. ice_reply_all_fltr - replay all filters stored in book keeping list.

These APIs will be used when switch rule feature is enabled.

---
 drivers/net/ice/base/ice_switch.c | 107 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   2 +
 2 files changed, 109 insertions(+)
drivers/net/ice/base/ice_switch.c +107 -0
index bfcb33ea6..a0c39b5d7 100644
@@ -2667,6 +2667,23 @@ ice_rem_sw_rule_info(struct ice_hw *hw, struct LIST_HEAD_TYPE *rule_head)
 }
 
 
+/**
+ * ice_rem_all_sw_rules_info
+ * @hw: pointer to the hardware structure
+ */
+void ice_rem_all_sw_rules_info(struct ice_hw *hw)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	u8 i;
+
+	for (i = 0; i < ICE_MAX_NUM_RECIPES; i++) {
+		struct LIST_HEAD_TYPE *rule_head;
+
+		rule_head = &sw->recp_list[i].filt_rules;
+		if (!sw->recp_list[i].adv_rule)
+			ice_rem_sw_rule_info(hw, rule_head);
+	}
+}
 
 /**
  * ice_cfg_dflt_vsi - change state of VSI to set/clear default
@@ -3747,6 +3764,96 @@ ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info)
 }
 
 /**
+ * ice_replay_fltr - Replay all the filters stored by a specific list head
+ * @hw: pointer to the hardware structure
+ * @list_head: list for which filters needs to be replayed
+ * @recp_id: Recipe ID for which rules need to be replayed
+ */
+static enum ice_status
+ice_replay_fltr(struct ice_hw *hw, u8 recp_id, struct LIST_HEAD_TYPE *list_head)
+{
+	struct ice_fltr_mgmt_list_entry *itr;
+	struct LIST_HEAD_TYPE l_head;
+	enum ice_status status = ICE_SUCCESS;
+
+	if (LIST_EMPTY(list_head))
+		return status;
+
+	/* Move entries from the given list_head to a temporary l_head so that
+	 * they can be replayed. Otherwise when trying to re-add the same
+	 * filter, the function will return already exists
+	 */
+	LIST_REPLACE_INIT(list_head, &l_head);
+
+	/* Mark the given list_head empty by reinitializing it so filters
+	 * could be added again by *handler
+	 */
+	LIST_FOR_EACH_ENTRY(itr, &l_head, ice_fltr_mgmt_list_entry,
+			    list_entry) {
+		struct ice_fltr_list_entry f_entry;
+
+		f_entry.fltr_info = itr->fltr_info;
+		if (itr->vsi_count < 2 && recp_id != ICE_SW_LKUP_VLAN) {
+			status = ice_add_rule_internal(hw, recp_id, &f_entry);
+			if (status != ICE_SUCCESS)
+				goto end;
+			continue;
+		}
+
+		/* Add a filter per VSI separately */
+		while (1) {
+			u16 vsi_handle;
+
+			vsi_handle =
+				ice_find_first_bit(itr->vsi_list_info->vsi_map,
+						   ICE_MAX_VSI);
+			if (!ice_is_vsi_valid(hw, vsi_handle))
+				break;
+
+			ice_clear_bit(vsi_handle, itr->vsi_list_info->vsi_map);
+			f_entry.fltr_info.vsi_handle = vsi_handle;
+			f_entry.fltr_info.fwd_id.hw_vsi_id =
+				ice_get_hw_vsi_num(hw, vsi_handle);
+			f_entry.fltr_info.fltr_act = ICE_FWD_TO_VSI;
+			if (recp_id == ICE_SW_LKUP_VLAN)
+				status = ice_add_vlan_internal(hw, &f_entry);
+			else
+				status = ice_add_rule_internal(hw, recp_id,
+							       &f_entry);
+			if (status != ICE_SUCCESS)
+				goto end;
+		}
+	}
+end:
+	/* Clear the filter management list */
+	ice_rem_sw_rule_info(hw, &l_head);
+	return status;
+}
+
+/**
+ * ice_replay_all_fltr - replay all filters stored in bookkeeping lists
+ * @hw: pointer to the hardware structure
+ *
+ * NOTE: This function does not clean up partially added filters on error.
+ * It is up to caller of the function to issue a reset or fail early.
+ */
+enum ice_status ice_replay_all_fltr(struct ice_hw *hw)
+{
+	struct ice_switch_info *sw = hw->switch_info;
+	enum ice_status status = ICE_SUCCESS;
+	u8 i;
+
+	for (i = 0; i < ICE_MAX_NUM_RECIPES; i++) {
+		struct LIST_HEAD_TYPE *head = &sw->recp_list[i].filt_rules;
+
+		status = ice_replay_fltr(hw, i, head);
+		if (status != ICE_SUCCESS)
+			return status;
+	}
+	return status;
+}
+
+/**
  * ice_replay_vsi_fltr - Replay filters for requested VSI
  * @hw: pointer to the hardware structure
  * @vsi_handle: driver VSI handle
drivers/net/ice/base/ice_switch.h +2 -0
index b396a486c..3cc2c10e8 100644
@@ -362,6 +362,7 @@ ice_aq_get_res_descs(struct ice_hw *hw, u16 num_entries,
 		     struct ice_sq_cd *cd);
 enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
+void ice_rem_all_sw_rules_info(struct ice_hw *hw);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status
@@ -409,6 +410,7 @@ ice_get_vsi_vlan_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
 
 
 
+enum ice_status ice_replay_all_fltr(struct ice_hw *hw);
 
 enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
Signature · 1 line
2.13.6
author
#61 lore raw

PATCH v2 16/37 net/ice/base: minor fix

In reply to Qi Zhang

1. ICE_SW_LKUP_LAST need to be handled correctly in ice_aq_alloc_free_vsi_list and ice_update_vsi_list_rule
2. ICE_SW_LKUP_ETHERTYPE_MAC need to be handled correctly in ice_update_vsi_lkup_fltr
3. free package segment pointer during ice_deinit_hw

Fixes c7dd15931183 ("net/ice/base: add virtual switch code")
Fixes 453d087ccaff ("net/ice/base: add common functions")
---
 drivers/net/ice/base/ice_common.c | 1 +
 drivers/net/ice/base/ice_switch.c | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ice/base/ice_common.c +1 -0
index 015db11e0..4085ccc12 100644
@@ -938,6 +938,7 @@ void ice_deinit_hw(struct ice_hw *hw)
 
 	ice_sched_cleanup_all(hw);
 	ice_sched_clear_agg(hw);
+	ice_free_seg(hw);
 
 	if (hw->port_info) {
 		ice_free(hw, hw->port_info);
drivers/net/ice/base/ice_switch.c +6 -2
index a0c39b5d7..e47c1d845 100644
@@ -792,7 +792,8 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE ||
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
 	    lkup_type == ICE_SW_LKUP_PROMISC ||
-	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN) {
+	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN ||
+	    lkup_type == ICE_SW_LKUP_LAST) {
 		sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_VSI_LIST_REP);
 	} else if (lkup_type == ICE_SW_LKUP_VLAN) {
 		sw_buf->res_type =
@@ -1492,7 +1493,8 @@ ice_update_vsi_list_rule(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi,
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE ||
 	    lkup_type == ICE_SW_LKUP_ETHERTYPE_MAC ||
 	    lkup_type == ICE_SW_LKUP_PROMISC ||
-	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN)
+	    lkup_type == ICE_SW_LKUP_PROMISC_VLAN ||
+	    lkup_type == ICE_SW_LKUP_LAST)
 		type = remove ? ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR :
 				ICE_AQC_SW_RULES_T_VSI_LIST_SET;
 	else if (lkup_type == ICE_SW_LKUP_VLAN)
@@ -3388,6 +3390,8 @@ ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,
 		break;
 	case ICE_SW_LKUP_ETHERTYPE:
 	case ICE_SW_LKUP_ETHERTYPE_MAC:
+		ice_remove_eth_mac(hw, &remove_list_head);
+		break;
 	case ICE_SW_LKUP_DFLT:
 		ice_debug(hw, ICE_DBG_SW,
 			  "Remove filters for this lookup type hasn't been implemented yet\n");
Signature · 1 line
2.13.6
author
#62 lore raw

PATCH v2 17/37 net/ice/base: update macros

In reply to Qi Zhang

Update macros for metadata and package flags.

---
 drivers/net/ice/base/ice_common.c    | 36 ++++++++---------
 drivers/net/ice/base/ice_flow.h      | 17 ++++++--
 drivers/net/ice/base/ice_lan_tx_rx.h | 77 +++++++++++++++++++++++-------------
 3 files changed, 80 insertions(+), 50 deletions(-)
drivers/net/ice/base/ice_common.c +18 -18
index 4085ccc12..e0fe06e9c 100644
@@ -365,22 +365,22 @@ static void ice_init_flex_flags(struct ice_hw *hw, enum ice_rxdid prof_id)
 	 */
 	case ICE_RXDID_FLEX_NIC:
 	case ICE_RXDID_FLEX_NIC_2:
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_PKT_FRG,
-				   ICE_RXFLG_UDP_GRE, ICE_RXFLG_PKT_DSI,
-				   ICE_RXFLG_FIN, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_PKT_FRG,
+				   ICE_FLG_UDP_GRE, ICE_FLG_PKT_DSI,
+				   ICE_FLG_FIN, idx++);
 		/* flex flag 1 is not used for flexi-flag programming, skipping
 		 * these four FLG64 bits.
 		 */
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_SYN, ICE_RXFLG_RST,
-				   ICE_RXFLG_PKT_DSI, ICE_RXFLG_PKT_DSI, idx++);
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_PKT_DSI,
-				   ICE_RXFLG_PKT_DSI, ICE_RXFLG_EVLAN_x8100,
-				   ICE_RXFLG_EVLAN_x9100, idx++);
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_VLAN_x8100,
-				   ICE_RXFLG_TNL_VLAN, ICE_RXFLG_TNL_MAC,
-				   ICE_RXFLG_TNL0, idx++);
-		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_RXFLG_TNL1, ICE_RXFLG_TNL2,
-				   ICE_RXFLG_PKT_DSI, ICE_RXFLG_PKT_DSI, idx);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_SYN, ICE_FLG_RST,
+				   ICE_FLG_PKT_DSI, ICE_FLG_PKT_DSI, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_PKT_DSI,
+				   ICE_FLG_PKT_DSI, ICE_FLG_EVLAN_x8100,
+				   ICE_FLG_EVLAN_x9100, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_VLAN_x8100,
+				   ICE_FLG_TNL_VLAN, ICE_FLG_TNL_MAC,
+				   ICE_FLG_TNL0, idx++);
+		ICE_PROG_FLG_ENTRY(hw, prof_id, ICE_FLG_TNL1, ICE_FLG_TNL2,
+				   ICE_FLG_PKT_DSI, ICE_FLG_PKT_DSI, idx);
 		break;
 
 	default:
@@ -399,17 +399,17 @@ static void ice_init_flex_flags(struct ice_hw *hw, enum ice_rxdid prof_id)
  */
 static void ice_init_flex_flds(struct ice_hw *hw, enum ice_rxdid prof_id)
 {
-	enum ice_flex_rx_mdid mdid;
+	enum ice_flex_mdid mdid;
 
 	switch (prof_id) {
 	case ICE_RXDID_FLEX_NIC:
 	case ICE_RXDID_FLEX_NIC_2:
-		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_RX_MDID_HASH_LOW, 0);
-		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_RX_MDID_HASH_HIGH, 1);
-		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_RX_MDID_FLOW_ID_LOWER, 2);
+		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_MDID_RX_HASH_LOW, 0);
+		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_MDID_RX_HASH_HIGH, 1);
+		ICE_PROG_FLEX_ENTRY(hw, prof_id, ICE_MDID_FLOW_ID_LOWER, 2);
 
 		mdid = (prof_id == ICE_RXDID_FLEX_NIC_2) ?
-			ICE_RX_MDID_SRC_VSI : ICE_RX_MDID_FLOW_ID_HIGH;
+			ICE_MDID_SRC_VSI : ICE_MDID_FLOW_ID_HIGH;
 
 		ICE_PROG_FLEX_ENTRY(hw, prof_id, mdid, 3);
 
drivers/net/ice/base/ice_flow.h +13 -4
index 265e1ee3e..3db10cd6f 100644
@@ -278,14 +278,23 @@ enum ice_flow_action_type {
 	ICE_FLOW_ACT_NOP,
 	ICE_FLOW_ACT_ALLOW,
 	ICE_FLOW_ACT_DROP,
-	ICE_FLOW_ACT_COUNT,
+	ICE_FLOW_ACT_CNTR_PKT,
 	ICE_FLOW_ACT_FWD_VSI,
 	ICE_FLOW_ACT_FWD_VSI_LIST,	/* Should be abstracted away */
 	ICE_FLOW_ACT_FWD_QUEUE,		/* Can Queues be abstracted away? */
 	ICE_FLOW_ACT_FWD_QUEUE_GROUP,	/* Can Queues be abstracted away? */
-	ICE_FLOW_ACTION_PUSH,
-	ICE_FLOW_ACTION_POP,
-	ICE_FLOW_ACTION_MODIFY,
+	ICE_FLOW_ACT_PUSH,
+	ICE_FLOW_ACT_POP,
+	ICE_FLOW_ACT_MODIFY,
+	ICE_FLOW_ACT_CNTR_BYTES,
+	ICE_FLOW_ACT_CNTR_PKT_BYTES,
+	ICE_FLOW_ACT_GENERIC_0,
+	ICE_FLOW_ACT_GENERIC_1,
+	ICE_FLOW_ACT_GENERIC_2,
+	ICE_FLOW_ACT_GENERIC_3,
+	ICE_FLOW_ACT_GENERIC_4,
+	ICE_FLOW_ACT_RPT_FLOW_ID,
+	ICE_FLOW_ACT_BUILD_PROF_IDX,
 };
 
 struct ice_flow_action {
drivers/net/ice/base/ice_lan_tx_rx.h +49 -28

88 lines not on this page · raw message

Signature · 1 line
2.13.6
author
#63 lore raw

PATCH v2 18/37 net/ice/base: code clean

In reply to Qi Zhang

Change below function as static and also relocated code line to align with kernel driver.

ice_aq_move_sched_elems
ice_sched_get_agg_node
ice_sched_set_node_bw_lmt
ice_sched_cfg_node_bw_alloc
ice_sched_add_agg_cfg
ice_sched_rm_agg_cfg
ice_sched_move_vsi_to_agg
ice_sched_del_rl_profile
ice_sched_rm_unused_rl_prof

---
 drivers/net/ice/base/ice_sched.c | 1038 +++++++++++++++++++-------------------
 drivers/net/ice/base/ice_sched.h |   24 -
 2 files changed, 519 insertions(+), 543 deletions(-)
drivers/net/ice/base/ice_sched.c +519 -519
index ab6097237..2dd9f6f6c 100644
@@ -462,7 +462,7 @@ ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req,
  *
  * Move scheduling elements (0x0408)
  */
-enum ice_status
+static enum ice_status
 ice_aq_move_sched_elems(struct ice_hw *hw, u16 grps_req,
 			struct ice_aqc_move_elem *buf, u16 buf_size,
 			u16 *grps_movd, struct ice_sq_cd *cd)
@@ -713,6 +713,41 @@ ice_aq_remove_rl_profile(struct ice_hw *hw, u16 num_profiles,
 }
 
 /**
+ * ice_sched_del_rl_profile - remove RL profile
+ * @hw: pointer to the HW struct
+ * @rl_info: rate limit profile information
+ *
+ * If the profile ID is not referenced anymore, it removes profile ID with
+ * its associated parameters from HW DB,and locally. The caller needs to
+ * hold scheduler lock.
+ */
+static enum ice_status
+ice_sched_del_rl_profile(struct ice_hw *hw,
+			 struct ice_aqc_rl_profile_info *rl_info)
+{
+	struct ice_aqc_rl_profile_generic_elem *buf;
+	u16 num_profiles_removed;
+	enum ice_status status;
+	u16 num_profiles = 1;
+
+	if (rl_info->prof_id_ref != 0)
+		return ICE_ERR_IN_USE;
+
+	/* Safe to remove profile ID */
+	buf = (struct ice_aqc_rl_profile_generic_elem *)
+		&rl_info->profile;
+	status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf),
+					  &num_profiles_removed, NULL);
+	if (status || num_profiles_removed != num_profiles)
+		return ICE_ERR_CFG;
+
+	/* Delete stale entry now */
+	LIST_DEL(&rl_info->list_entry);
+	ice_free(hw, rl_info);
+	return status;
+}
+
+/**
  * ice_sched_clear_rl_prof - clears RL prof entries
  * @pi: port information structure
  *
@@ -1468,7 +1503,7 @@ ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
  * This function retrieves an aggregator node for a given aggregator ID from
  * a given TC branch
  */
-struct ice_sched_node *
+static struct ice_sched_node *
 ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
 		       u32 agg_id)
 {
@@ -2071,6 +2106,220 @@ ice_get_agg_info(struct ice_hw *hw, u32 agg_id)
 }
 
 /**
+ * ice_sched_get_free_vsi_parent - Find a free parent node in aggregator subtree
+ * @hw: pointer to the HW struct
+ * @node: pointer to a child node
+ * @num_nodes: num nodes count array
+ *
+ * This function walks through the aggregator subtree to find a free parent
+ * node
+ */
+static struct ice_sched_node *
+ice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node,
+			      u16 *num_nodes)
+{
+	u8 l = node->tx_sched_layer;
+	u8 vsil, i;
+
+	vsil = ice_sched_get_vsi_layer(hw);
+
+	/* Is it VSI parent layer ? */
+	if (l == vsil - 1)
+		return (node->num_children < hw->max_children[l]) ? node : NULL;
+
+	/* We have intermediate nodes. Let's walk through the subtree. If the
+	 * intermediate node has space to add a new node then clear the count
+	 */
+	if (node->num_children < hw->max_children[l])
+		num_nodes[l] = 0;
+	/* The below recursive call is intentional and wouldn't go more than
+	 * 2 or 3 iterations.
+	 */
+
+	for (i = 0; i < node->num_children; i++) {
+		struct ice_sched_node *parent;
+
+		parent = ice_sched_get_free_vsi_parent(hw, node->children[i],
+						       num_nodes);
+		if (parent)
+			return parent;
+	}
+
+	return NULL;
+}
+
+/**
+ * ice_sched_update_parent - update the new parent in SW DB
+ * @new_parent: pointer to a new parent node
+ * @node: pointer to a child node
+ *
+ * This function removes the child from the old parent and adds it to a new
+ * parent
+ */
+static void
+ice_sched_update_parent(struct ice_sched_node *new_parent,
+			struct ice_sched_node *node)
+{
+	struct ice_sched_node *old_parent;
+	u8 i, j;
+
+	old_parent = node->parent;
+
+	/* update the old parent children */
+	for (i = 0; i < old_parent->num_children; i++)
+		if (old_parent->children[i] == node) {
+			for (j = i + 1; j < old_parent->num_children; j++)
+				old_parent->children[j - 1] =
+					old_parent->children[j];
+			old_parent->num_children--;
+			break;
+		}
+
+	/* now move the node to a new parent */
+	new_parent->children[new_parent->num_children++] = node;
+	node->parent = new_parent;
+	node->info.parent_teid = new_parent->info.node_teid;
+}
+
+/**
+ * ice_sched_move_nodes - move child nodes to a given parent
+ * @pi: port information structure
+ * @parent: pointer to parent node
+ * @num_items: number of child nodes to be moved
+ * @list: pointer to child node teids
+ *
+ * This function move the child nodes to a given parent.
+ */
+static enum ice_status
+ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
+		     u16 num_items, u32 *list)
+{
+	struct ice_aqc_move_elem *buf;
+	struct ice_sched_node *node;
+	enum ice_status status = ICE_SUCCESS;
+	struct ice_hw *hw;
+	u16 grps_movd = 0;
+	u8 i;
+
+	hw = pi->hw;
+
+	if (!parent || !num_items)
+		return ICE_ERR_PARAM;
+
+	/* Does parent have enough space */
+	if (parent->num_children + num_items >=
+	    hw->max_children[parent->tx_sched_layer])
+		return ICE_ERR_AQ_FULL;
+
+	buf = (struct ice_aqc_move_elem *)ice_malloc(hw, sizeof(*buf));
+	if (!buf)
+		return ICE_ERR_NO_MEMORY;
+
+	for (i = 0; i < num_items; i++) {
+		node = ice_sched_find_node_by_teid(pi->root, list[i]);
+		if (!node) {
+			status = ICE_ERR_PARAM;
+			goto move_err_exit;
+		}
+
+		buf->hdr.src_parent_teid = node->info.parent_teid;
+		buf->hdr.dest_parent_teid = parent->info.node_teid;
+		buf->teid[0] = node->info.node_teid;
+		buf->hdr.num_elems = CPU_TO_LE16(1);
+		status = ice_aq_move_sched_elems(hw, 1, buf, sizeof(*buf),
+						 &grps_movd, NULL);
+		if (status && grps_movd != 1) {
+			status = ICE_ERR_CFG;
+			goto move_err_exit;
+		}
+
+		/* update the SW DB */
+		ice_sched_update_parent(parent, node);
+	}
+
+move_err_exit:
+	ice_free(hw, buf);
+	return status;
+}
+
+/**
+ * ice_sched_move_vsi_to_agg - move VSI to aggregator node
+ * @pi: port information structure
+ * @vsi_handle: software VSI handle
+ * @agg_id: aggregator ID
+ * @tc: TC number
+ *
+ * This function moves a VSI to an aggregator node or its subtree.
+ * Intermediate nodes may be created if required.
+ */
+static enum ice_status
+ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
+			  u8 tc)
+{
+	struct ice_sched_node *vsi_node, *agg_node, *tc_node, *parent;
+	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
+	u32 first_node_teid, vsi_teid;
+	enum ice_status status;
+	u16 num_nodes_added;
+	u8 aggl, vsil, i;
+
+	tc_node = ice_sched_get_tc_node(pi, tc);
+	if (!tc_node)
+		return ICE_ERR_CFG;
+
+	agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+	if (!agg_node)
+		return ICE_ERR_DOES_NOT_EXIST;
+
+	vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+	if (!vsi_node)
+		return ICE_ERR_DOES_NOT_EXIST;
+
+	aggl = ice_sched_get_agg_layer(pi->hw);
+	vsil = ice_sched_get_vsi_layer(pi->hw);
+
+	/* set intermediate node count to 1 between aggregator and VSI layers */
+	for (i = aggl + 1; i < vsil; i++)
+		num_nodes[i] = 1;
+
+	/* Check if the aggregator subtree has any free node to add the VSI */
+	for (i = 0; i < agg_node->num_children; i++) {
+		parent = ice_sched_get_free_vsi_parent(pi->hw,
+						       agg_node->children[i],
+						       num_nodes);
+		if (parent)
+			goto move_nodes;
+	}
+
+	/* add new nodes */
+	parent = agg_node;
+	for (i = aggl + 1; i < vsil; i++) {
+		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
+						      num_nodes[i],
+						      &first_node_teid,
+						      &num_nodes_added);
+		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
+			return ICE_ERR_CFG;
+
+		/* The newly added node can be a new parent for the next
+		 * layer nodes
+		 */
+		if (num_nodes_added)
+			parent = ice_sched_find_node_by_teid(tc_node,
+							     first_node_teid);
+		else
+			parent = parent->children[0];
+
+		if (!parent)
+			return ICE_ERR_CFG;
+	}
+
+move_nodes:
+	vsi_teid = LE32_TO_CPU(vsi_node->info.node_teid);
+	return ice_sched_move_nodes(pi, parent, 1, &vsi_teid);
+}
+
+/**
  * ice_move_all_vsi_to_dflt_agg - move all VSI(s) to default aggregator
  * @pi: port information structure
  * @agg_info: aggregator info
@@ -2114,20 +2363,89 @@ ice_move_all_vsi_to_dflt_agg(struct ice_port_info *pi,
 }
 
 /**
- * ice_rm_agg_cfg_tc - remove aggregator configuration for TC
+ * ice_sched_is_agg_inuse - check whether the aggregator is in use or not
  * @pi: port information structure
- * @agg_info: aggregator ID
- * @tc: TC number
- * @rm_vsi_info: bool value true or false
+ * @node: node pointer
  *
- * This function removes aggregator reference to VSI of given TC. It removes
- * the aggregator configuration completely for requested TC. The caller needs
- * to hold the scheduler lock.
+ * This function checks whether the aggregator is attached with any VSI or not.
  */
-static enum ice_status
-ice_rm_agg_cfg_tc(struct ice_port_info *pi, struct ice_sched_agg_info *agg_info,
-		  u8 tc, bool rm_vsi_info)
-{
+static bool
+ice_sched_is_agg_inuse(struct ice_port_info *pi, struct ice_sched_node *node)
+{
+	u8 vsil, i;
+
+	vsil = ice_sched_get_vsi_layer(pi->hw);
+	if (node->tx_sched_layer < vsil - 1) {
+		for (i = 0; i < node->num_children; i++)
+			if (ice_sched_is_agg_inuse(pi, node->children[i]))
+				return true;
+		return false;
+	} else {
+		return node->num_children ? true : false;
+	}
+}
+
+/**
+ * ice_sched_rm_agg_cfg - remove the aggregator node
+ * @pi: port information structure
+ * @agg_id: aggregator ID
+ * @tc: TC number
+ *
+ * This function removes the aggregator node and intermediate nodes if any
+ * from the given TC
+ */
+static enum ice_status
+ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
+{
+	struct ice_sched_node *tc_node, *agg_node;
+	struct ice_hw *hw = pi->hw;
+
+	tc_node = ice_sched_get_tc_node(pi, tc);
+	if (!tc_node)
+		return ICE_ERR_CFG;
+
+	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	if (!agg_node)
+		return ICE_ERR_DOES_NOT_EXIST;
+
+	/* Can't remove the aggregator node if it has children */
+	if (ice_sched_is_agg_inuse(pi, agg_node))
+		return ICE_ERR_IN_USE;
+
+	/* need to remove the whole subtree if aggregator node is the
+	 * only child.
+	 */
+	while (agg_node->tx_sched_layer > hw->sw_entry_point_layer) {
+		struct ice_sched_node *parent = agg_node->parent;
+
+		if (!parent)
+			return ICE_ERR_CFG;
+
+		if (parent->num_children > 1)
+			break;
+
+		agg_node = parent;
+	}
+
+	ice_free_sched_node(pi, agg_node);
+	return ICE_SUCCESS;
+}
+
+/**
+ * ice_rm_agg_cfg_tc - remove aggregator configuration for TC
+ * @pi: port information structure
+ * @agg_info: aggregator ID
+ * @tc: TC number
+ * @rm_vsi_info: bool value true or false
+ *
+ * This function removes aggregator reference to VSI of given TC. It removes
+ * the aggregator configuration completely for requested TC. The caller needs
+ * to hold the scheduler lock.
+ */
+static enum ice_status
+ice_rm_agg_cfg_tc(struct ice_port_info *pi, struct ice_sched_agg_info *agg_info,
+		  u8 tc, bool rm_vsi_info)
+{
 	enum ice_status status = ICE_SUCCESS;
 
 	/* If nothing to remove - return success */
@@ -2172,6 +2490,89 @@ ice_save_agg_tc_bitmap(struct ice_port_info *pi, u32 agg_id,
 }
 
 /**
+ * ice_sched_add_agg_cfg - create an aggregator node
+ * @pi: port information structure
+ * @agg_id: aggregator ID
+ * @tc: TC number
+ *
+ * This function creates an aggregator node and intermediate nodes if required
+ * for the given TC
+ */
+static enum ice_status
+ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
+{
+	struct ice_sched_node *parent, *agg_node, *tc_node;
+	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
+	enum ice_status status = ICE_SUCCESS;
+	struct ice_hw *hw = pi->hw;
+	u32 first_node_teid;
+	u16 num_nodes_added;
+	u8 i, aggl;
+
+	tc_node = ice_sched_get_tc_node(pi, tc);
+	if (!tc_node)
+		return ICE_ERR_CFG;
+
+	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+	/* Does Agg node already exist ? */
+	if (agg_node)
+		return status;
+
+	aggl = ice_sched_get_agg_layer(hw);
+
+	/* need one node in Agg layer */
+	num_nodes[aggl] = 1;
+
+	/* Check whether the intermediate nodes have space to add the
+	 * new aggregator. If they are full, then SW needs to allocate a new
+	 * intermediate node on those layers
+	 */
+	for (i = hw->sw_entry_point_layer; i < aggl; i++) {
+		parent = ice_sched_get_first_node(hw, tc_node, i);
+
+		/* scan all the siblings */
+		while (parent) {
+			if (parent->num_children < hw->max_children[i])
+				break;
+			parent = parent->sibling;
+		}
+
+		/* all the nodes are full, reserve one for this layer */
+		if (!parent)
+			num_nodes[i]++;
+	}
+
+	/* add the aggregator node */
+	parent = tc_node;
+	for (i = hw->sw_entry_point_layer; i <= aggl; i++) {
+		if (!parent)
+			return ICE_ERR_CFG;
+
+		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
+						      num_nodes[i],
+						      &first_node_teid,
+						      &num_nodes_added);
+		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
+			return ICE_ERR_CFG;
+
+		/* The newly added node can be a new parent for the next
+		 * layer nodes
+		 */
+		if (num_nodes_added) {
+			parent = ice_sched_find_node_by_teid(tc_node,
+							     first_node_teid);
+			/* register aggregator ID with the aggregator node */
+			if (parent && i == aggl)
+				parent->agg_id = agg_id;
+		} else {
+			parent = parent->children[0];
+		}
+	}
+
+	return ICE_SUCCESS;
+}
+
+/**
  * ice_sched_cfg_agg - configure aggregator node
  * @pi: port information structure
  * @agg_id: aggregator ID
@@ -2406,6 +2807,109 @@ ice_sched_assoc_vsi_to_agg(struct ice_port_info *pi, u32 agg_id,
 }
 
 /**
+ * ice_sched_rm_unused_rl_prof - remove unused RL profile
+ * @pi: port information structure
+ *
+ * This function removes unused rate limit profiles from the HW and
+ * SW DB. The caller needs to hold scheduler lock.
+ */
+static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi)
+{
+	u8 ln;
+
+	for (ln = 0; ln < pi->hw->num_tx_sched_layers; ln++) {
+		struct ice_aqc_rl_profile_info *rl_prof_elem;
+		struct ice_aqc_rl_profile_info *rl_prof_tmp;
+
+		LIST_FOR_EACH_ENTRY_SAFE(rl_prof_elem, rl_prof_tmp,
+					 &pi->rl_prof_list[ln],
+					 ice_aqc_rl_profile_info, list_entry) {
+			if (!ice_sched_del_rl_profile(pi->hw, rl_prof_elem))
+				ice_debug(pi->hw, ICE_DBG_SCHED,
+					  "Removed rl profile\n");
+		}
+	}
+}
+
+/**
+ * ice_sched_update_elem - update element
+ * @hw: pointer to the HW struct
+ * @node: pointer to node
+ * @info: node info to update
+ *
+ * It updates the HW DB, and local SW DB of node. It updates the scheduling
+ * parameters of node from argument info data buffer (Info->data buf) and
+ * returns success or error on config sched element failure. The caller
+ * needs to hold scheduler lock.
+ */
+static enum ice_status
+ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node,
+		      struct ice_aqc_txsched_elem_data *info)
+{
+	struct ice_aqc_conf_elem buf;
+	enum ice_status status;
+	u16 elem_cfgd = 0;
+	u16 num_elems = 1;
+
+	buf.generic[0] = *info;
+	/* Parent TEID is reserved field in this aq call */
+	buf.generic[0].parent_teid = 0;
+	/* Element type is reserved field in this aq call */
+	buf.generic[0].data.elem_type = 0;
+	/* Flags is reserved field in this aq call */
+	buf.generic[0].data.flags = 0;
+
+	/* Update HW DB */
+	/* Configure element node */
+	status = ice_aq_cfg_sched_elems(hw, num_elems, &buf, sizeof(buf),
+					&elem_cfgd, NULL);
+	if (status || elem_cfgd != num_elems) {
+		ice_debug(hw, ICE_DBG_SCHED, "Config sched elem error\n");
+		return ICE_ERR_CFG;
+	}
+
+	/* Config success case */
+	/* Now update local SW DB */
+	/* Only copy the data portion of info buffer */
+	node->info.data = info->data;
+	return status;
+}
+
+/**
+ * ice_sched_cfg_node_bw_alloc - configure node BW weight/alloc params
+ * @hw: pointer to the HW struct
+ * @node: sched node to configure
+ * @rl_type: rate limit type CIR, EIR, or shared
+ * @bw_alloc: BW weight/allocation
+ *
+ * This function configures node element's BW allocation.
+ */
+static enum ice_status
+ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node,
+			    enum ice_rl_type rl_type, u8 bw_alloc)
+{
+	struct ice_aqc_txsched_elem_data buf;
+	struct ice_aqc_txsched_elem *data;
+	enum ice_status status;
+
+	buf = node->info;
+	data = &buf.data;
+	if (rl_type == ICE_MIN_BW) {
+		data->valid_sections |= ICE_AQC_ELEM_VALID_CIR;
+		data->cir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
+	} else if (rl_type == ICE_MAX_BW) {
+		data->valid_sections |= ICE_AQC_ELEM_VALID_EIR;
+		data->eir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
+	} else {
+		return ICE_ERR_PARAM;
+	}
+
+	/* Configure element */
+	status = ice_sched_update_elem(hw, node, &buf);
+	return status;
+}
+
+/**
  * ice_move_vsi_to_agg - moves VSI to new or default aggregator
  * @pi: port information structure
  * @agg_id: aggregator ID
@@ -3372,110 +3876,6 @@ ice_sched_add_rl_profile(struct ice_port_info *pi,
 }
 
 /**
- * ice_sched_del_rl_profile - remove rl profile
- * @hw: pointer to the hw struct
- * @rl_info: rate limit profile information
- *
- * If the profile id is not referenced anymore, it removes profile id with
- * its associated parameters from hw db,and locally. The caller needs to
- * hold scheduler lock.
- */
-enum ice_status
-ice_sched_del_rl_profile(struct ice_hw *hw,
-			 struct ice_aqc_rl_profile_info *rl_info)
-{
-	struct ice_aqc_rl_profile_generic_elem *buf;
-	u16 num_profiles_removed;
-	enum ice_status status;
-	u16 num_profiles = 1;
-
-	if (rl_info->prof_id_ref != 0)
-		return ICE_ERR_IN_USE;
-
-	/* Safe to remove profile id */
-	buf = (struct ice_aqc_rl_profile_generic_elem *)
-		&rl_info->profile;
-	status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf),
-					  &num_profiles_removed, NULL);
-	if (status || num_profiles_removed != num_profiles)
-		return ICE_ERR_CFG;
-
-	/* Delete stale entry now */
-	LIST_DEL(&rl_info->list_entry);
-	ice_free(hw, rl_info);
-	return status;
-}
-
-/**
- * ice_sched_rm_unused_rl_prof - remove unused rl profile
- * @pi: port information structure
- *
- * This function removes unused rate limit profiles from the hw and
- * SW DB. The caller needs to hold scheduler lock.
- */
-void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi)
-{
-	u8 ln;
-
-	for (ln = 0; ln < pi->hw->num_tx_sched_layers; ln++) {
-		struct ice_aqc_rl_profile_info *rl_prof_elem;
-		struct ice_aqc_rl_profile_info *rl_prof_tmp;
-
-		LIST_FOR_EACH_ENTRY_SAFE(rl_prof_elem, rl_prof_tmp,
-					 &pi->rl_prof_list[ln],
-					 ice_aqc_rl_profile_info, list_entry) {
-			if (!ice_sched_del_rl_profile(pi->hw, rl_prof_elem))
-				ice_debug(pi->hw, ICE_DBG_SCHED,
-					  "Removed rl profile\n");
-		}
-	}
-}
-
-/**
- * ice_sched_update_elem - update element
- * @hw: pointer to the hw struct
- * @node: pointer to node
- * @info: node info to update
- *
- * It updates the HW DB, and local SW DB of node. It updates the scheduling
- * parameters of node from argument info data buffer (Info->data buf) and
- * returns success or error on config sched element failure. The caller
- * needs to hold scheduler lock.
- */
-static enum ice_status
-ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node,
-		      struct ice_aqc_txsched_elem_data *info)
-{
-	struct ice_aqc_conf_elem buf;
-	enum ice_status status;
-	u16 elem_cfgd = 0;
-	u16 num_elems = 1;
-
-	buf.generic[0] = *info;
-	/* Parent teid is reserved field in this aq call */
-	buf.generic[0].parent_teid = 0;
-	/* Element type is reserved field in this aq call */
-	buf.generic[0].data.elem_type = 0;
-	/* Flags is reserved field in this aq call */
-	buf.generic[0].data.flags = 0;
-
-	/* Update HW DB */
-	/* Configure element node */
-	status = ice_aq_cfg_sched_elems(hw, num_elems, &buf, sizeof(buf),
-					&elem_cfgd, NULL);
-	if (status || elem_cfgd != num_elems) {
-		ice_debug(hw, ICE_DBG_SCHED, "Config sched elem error\n");
-		return ICE_ERR_CFG;
-	}
-
-	/* Config success case */
-	/* Now update local SW DB */
-	/* Only copy the data portion of info buffer */
-	node->info.data = info->data;
-	return status;
-}
-
-/**
  * ice_sched_cfg_node_bw_lmt - configure node sched params
  * @hw: pointer to the HW struct
  * @node: sched node to configure
@@ -3841,7 +4241,7 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node,
  * It updates node's BW limit parameters like BW RL profile ID of type CIR,
  * EIR, or SRL. The caller needs to hold scheduler lock.
  */
-enum ice_status
+static enum ice_status
 ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node,
 			  enum ice_rl_type rl_type, u32 bw)
 {
@@ -4588,7 +4988,7 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
 
 /**
  * ice_sched_cfg_sibl_node_prio - configure node sibling priority
- * @hw: pointer to the hw struct
+ * @hw: pointer to the HW struct
  * @node: sched node to configure
  * @priority: sibling priority
  *
@@ -4617,406 +5017,6 @@ ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
 }
 
 /**
- * ice_sched_cfg_node_bw_alloc - configure node bw weight/alloc params
- * @hw: pointer to the hw struct
- * @node: sched node to configure
- * @rl_type: rate limit type cir, eir, or shared
- * @bw_alloc: bw weight/allocation
- *
- * This function configures node element's bw allocation.
- */
-enum ice_status
-ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node,
-			    enum ice_rl_type rl_type, u8 bw_alloc)
-{
-	struct ice_aqc_txsched_elem_data buf;
-	struct ice_aqc_txsched_elem *data;
-	enum ice_status status;
-
-	buf = node->info;
-	data = &buf.data;
-	if (rl_type == ICE_MIN_BW) {
-		data->valid_sections |= ICE_AQC_ELEM_VALID_CIR;
-		data->cir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
-	} else if (rl_type == ICE_MAX_BW) {
-		data->valid_sections |= ICE_AQC_ELEM_VALID_EIR;
-		data->eir_bw.bw_alloc = CPU_TO_LE16(bw_alloc);
-	} else {
-		return ICE_ERR_PARAM;
-	}
-
-	/* Configure element */
-	status = ice_sched_update_elem(hw, node, &buf);
-	return status;
-}
-
-/**
- * ice_sched_add_agg_cfg - create an aggregator node
- * @pi: port information structure
- * @agg_id: aggregator id
- * @tc: TC number
- *
- * This function creates an aggregator node and intermediate nodes if required
- * for the given TC
- */
-enum ice_status
-ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
-{
-	struct ice_sched_node *parent, *agg_node, *tc_node;
-	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
-	enum ice_status status = ICE_SUCCESS;
-	struct ice_hw *hw = pi->hw;
-	u32 first_node_teid;
-	u16 num_nodes_added;
-	u8 i, aggl;
-
-	tc_node = ice_sched_get_tc_node(pi, tc);
-	if (!tc_node)
-		return ICE_ERR_CFG;
-
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
-	/* Does Agg node already exist ? */
-	if (agg_node)
-		return status;
-
-	aggl = ice_sched_get_agg_layer(hw);
-
-	/* need one node in Agg layer */
-	num_nodes[aggl] = 1;
-
-	/* Check whether the intermediate nodes have space to add the
-	 * new agg. If they are full, then SW needs to allocate a new
-	 * intermediate node on those layers
-	 */
-	for (i = hw->sw_entry_point_layer; i < aggl; i++) {
-		parent = ice_sched_get_first_node(hw, tc_node, i);
-
-		/* scan all the siblings */
-		while (parent) {
-			if (parent->num_children < hw->max_children[i])
-				break;
-			parent = parent->sibling;
-		}
-
-		/* all the nodes are full, reserve one for this layer */
-		if (!parent)
-			num_nodes[i]++;
-	}
-
-	/* add the agg node */
-	parent = tc_node;
-	for (i = hw->sw_entry_point_layer; i <= aggl; i++) {
-		if (!parent)
-			return ICE_ERR_CFG;
-
-		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
-						      num_nodes[i],
-						      &first_node_teid,
-						      &num_nodes_added);
-		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
-			return ICE_ERR_CFG;
-
-		/* The newly added node can be a new parent for the next
-		 * layer nodes
-		 */
-		if (num_nodes_added) {
-			parent = ice_sched_find_node_by_teid(tc_node,
-							     first_node_teid);
-			/* register the aggregator id with the agg node */
-			if (parent && i == aggl)
-				parent->agg_id = agg_id;
-		} else {
-			parent = parent->children[0];
-		}
-	}
-
-	return ICE_SUCCESS;
-}
-
-/**
- * ice_sched_is_agg_inuse - check whether the agg is in use or not
- * @pi: port information structure
- * @node: node pointer
- *
- * This function checks whether the agg is attached with any vsi or not.
- */
-static bool
-ice_sched_is_agg_inuse(struct ice_port_info *pi, struct ice_sched_node *node)
-{
-	u8 vsil, i;
-
-	vsil = ice_sched_get_vsi_layer(pi->hw);
-	if (node->tx_sched_layer < vsil - 1) {
-		for (i = 0; i < node->num_children; i++)
-			if (ice_sched_is_agg_inuse(pi, node->children[i]))
-				return true;
-		return false;
-	} else {
-		return node->num_children ? true : false;
-	}
-}
-
-/**
- * ice_sched_rm_agg_cfg - remove the aggregator node
- * @pi: port information structure
- * @agg_id: aggregator id
- * @tc: TC number
- *
- * This function removes the aggregator node and intermediate nodes if any
- * from the given TC
- */
-enum ice_status
-ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
-{
-	struct ice_sched_node *tc_node, *agg_node;
-	struct ice_hw *hw = pi->hw;
-
-	tc_node = ice_sched_get_tc_node(pi, tc);
-	if (!tc_node)
-		return ICE_ERR_CFG;
-
-	agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
-	if (!agg_node)
-		return ICE_ERR_DOES_NOT_EXIST;
-
-	/* Can't remove the agg node if it has children */
-	if (ice_sched_is_agg_inuse(pi, agg_node))
-		return ICE_ERR_IN_USE;
-
-	/* need to remove the whole subtree if agg node is the
-	 * only child.
-	 */
-	while (agg_node->tx_sched_layer > hw->sw_entry_point_layer) {
-		struct ice_sched_node *parent = agg_node->parent;
-
-		if (!parent)
-			return ICE_ERR_CFG;
-
-		if (parent->num_children > 1)
-			break;
-
-		agg_node = parent;
-	}
-
-	ice_free_sched_node(pi, agg_node);
-	return ICE_SUCCESS;
-}
-
-/**
- * ice_sched_get_free_vsi_parent - Find a free parent node in agg subtree
- * @hw: pointer to the hw struct
- * @node: pointer to a child node
- * @num_nodes: num nodes count array
- *
- * This function walks through the aggregator subtree to find a free parent
- * node
- */
-static struct ice_sched_node *
-ice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node,
-			      u16 *num_nodes)
-{
-	u8 l = node->tx_sched_layer;
-	u8 vsil, i;
-
-	vsil = ice_sched_get_vsi_layer(hw);
-
-	/* Is it VSI parent layer ? */
-	if (l == vsil - 1)
-		return (node->num_children < hw->max_children[l]) ? node : NULL;
-
-	/* We have intermediate nodes. Let's walk through the subtree. If the
-	 * intermediate node has space to add a new node then clear the count
-	 */
-	if (node->num_children < hw->max_children[l])
-		num_nodes[l] = 0;
-	/* The below recursive call is intentional and wouldn't go more than
-	 * 2 or 3 iterations.
-	 */
-
-	for (i = 0; i < node->num_children; i++) {
-		struct ice_sched_node *parent;
-
-		parent = ice_sched_get_free_vsi_parent(hw, node->children[i],
-						       num_nodes);
-		if (parent)
-			return parent;
-	}
-
-	return NULL;
-}
-
-/**
- * ice_sched_update_new_parent - update the new parent in SW DB
- * @new_parent: pointer to a new parent node
- * @node: pointer to a child node
- *
- * This function removes the child from the old parent and adds it to a new
- * parent
- */
-static void
-ice_sched_update_parent(struct ice_sched_node *new_parent,
-			struct ice_sched_node *node)
-{
-	struct ice_sched_node *old_parent;
-	u8 i, j;
-
-	old_parent = node->parent;
-
-	/* update the old parent children */
-	for (i = 0; i < old_parent->num_children; i++)
-		if (old_parent->children[i] == node) {
-			for (j = i + 1; j < old_parent->num_children; j++)
-				old_parent->children[j - 1] =
-					old_parent->children[j];
-			old_parent->num_children--;
-			break;
-		}
-
-	/* now move the node to a new parent */
-	new_parent->children[new_parent->num_children++] = node;
-	node->parent = new_parent;
-	node->info.parent_teid = new_parent->info.node_teid;
-}
-
-/**
- * ice_sched_move_nodes - move child nodes to a given parent
- * @pi: port information structure
- * @parent: pointer to parent node
- * @num_items: number of child nodes to be moved
- * @list: pointer to child node teids
- *
- * This function move the child nodes to a given parent.
- */
-static enum ice_status
-ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
-		     u16 num_items, u32 *list)
-{
-	struct ice_aqc_move_elem *buf;
-	struct ice_sched_node *node;
-	enum ice_status status = ICE_SUCCESS;
-	struct ice_hw *hw;
-	u16 grps_movd = 0;
-	u8 i;
-
-	hw = pi->hw;
-
-	if (!parent || !num_items)
-		return ICE_ERR_PARAM;
-
-	/* Does parent have enough space */
-	if (parent->num_children + num_items >=
-	    hw->max_children[parent->tx_sched_layer])
-		return ICE_ERR_AQ_FULL;
-
-	buf = (struct ice_aqc_move_elem *) ice_malloc(hw, sizeof(*buf));
-	if (!buf)
-		return ICE_ERR_NO_MEMORY;
-
-	for (i = 0; i < num_items; i++) {
-		node = ice_sched_find_node_by_teid(pi->root, list[i]);
-		if (!node) {
-			status = ICE_ERR_PARAM;
-			goto move_err_exit;
-		}
-
-		buf->hdr.src_parent_teid = node->info.parent_teid;
-		buf->hdr.dest_parent_teid = parent->info.node_teid;
-		buf->teid[0] = node->info.node_teid;
-		buf->hdr.num_elems = CPU_TO_LE16(1);
-		status = ice_aq_move_sched_elems(hw, 1, buf, sizeof(*buf),
-						 &grps_movd, NULL);
-		if (status && grps_movd != 1) {
-			status = ICE_ERR_CFG;
-			goto move_err_exit;
-		}
-
-		/* update the SW DB */
-		ice_sched_update_parent(parent, node);
-	}
-
-move_err_exit:
-	ice_free(hw, buf);
-	return status;
-}
-
-/**
- * ice_sched_move_vsi_to_agg - move VSI to aggregator node
- * @pi: port information structure
- * @vsi_handle: software VSI handle
- * @agg_id: aggregator id
- * @tc: TC number
- *
- * This function moves a VSI to an aggregator node or its subtree.
- * Intermediate nodes may be created if required.
- */
-enum ice_status
-ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
-			  u8 tc)
-{
-	struct ice_sched_node *vsi_node, *agg_node, *tc_node, *parent;
-	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
-	u32 first_node_teid, vsi_teid;
-	enum ice_status status;
-	u16 num_nodes_added;
-	u8 aggl, vsil, i;
-
-	tc_node = ice_sched_get_tc_node(pi, tc);
-	if (!tc_node)
-		return ICE_ERR_CFG;
-
-	agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
-	if (!agg_node)
-		return ICE_ERR_DOES_NOT_EXIST;
-
-	vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
-	if (!vsi_node)
-		return ICE_ERR_DOES_NOT_EXIST;
-
-	aggl = ice_sched_get_agg_layer(pi->hw);
-	vsil = ice_sched_get_vsi_layer(pi->hw);
-
-	/* initialize intermediate node count to 1 between agg and VSI layers */
-	for (i = aggl + 1; i < vsil; i++)
-		num_nodes[i] = 1;
-
-	/* Check whether the agg subtree has any free node to add the VSI */
-	for (i = 0; i < agg_node->num_children; i++) {
-		parent = ice_sched_get_free_vsi_parent(pi->hw,
-						       agg_node->children[i],
-						       num_nodes);
-		if (parent)
-			goto move_nodes;
-	}
-
-	/* add new nodes */
-	parent = agg_node;
-	for (i = aggl + 1; i < vsil; i++) {
-		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
-						      num_nodes[i],
-						      &first_node_teid,
-						      &num_nodes_added);
-		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
-			return ICE_ERR_CFG;
-
-		/* The newly added node can be a new parent for the next
-		 * layer nodes
-		 */
-		if (num_nodes_added)
-			parent = ice_sched_find_node_by_teid(tc_node,
-							     first_node_teid);
-		else
-			parent = parent->children[0];
-
-		if (!parent)
-			return ICE_ERR_CFG;
-	}
-
-move_nodes:
-	vsi_teid = LE32_TO_CPU(vsi_node->info.node_teid);
-	return ice_sched_move_nodes(pi, parent, 1, &vsi_teid);
-}
-
-/**
  * ice_cfg_rl_burst_size - Set burst size value
  * @hw: pointer to the HW struct
  * @bytes: burst size in bytes
drivers/net/ice/base/ice_sched.h +0 -24
index 61fa6a85b..09de765ff 100644
@@ -76,10 +76,6 @@ ice_aq_cfg_l2_node_cgd(struct ice_hw *hw, u16 num_nodes,
 		       struct ice_aqc_cfg_l2_node_cgd_data *buf, u16 buf_size,
 		       struct ice_sq_cd *cd);
 enum ice_status
-ice_aq_move_sched_elems(struct ice_hw *hw, u16 grps_req,
-			struct ice_aqc_move_elem *buf, u16 buf_size,
-			u16 *grps_movd, struct ice_sq_cd *cd);
-enum ice_status
 ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
 			 struct ice_aqc_get_elem *buf, u16 buf_size,
 			 u16 *elems_ret, struct ice_sq_cd *cd);
@@ -109,9 +105,6 @@ ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
 		  u8 owner, bool enable);
 enum ice_status ice_rm_vsi_lan_cfg(struct ice_port_info *pi, u16 vsi_handle);
 struct ice_sched_node *
-ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
-		       u32 agg_id);
-struct ice_sched_node *
 ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
 		       u16 vsi_handle);
 bool ice_sched_is_tree_balanced(struct ice_hw *hw, struct ice_sched_node *node);
@@ -177,9 +170,6 @@ bool
 ice_sched_find_node_in_subtree(struct ice_hw *hw, struct ice_sched_node *base,
 			       struct ice_sched_node *node);
 enum ice_status
-ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node,
-			  enum ice_rl_type rl_type, u32 bw);
-enum ice_status
 ice_sched_set_agg_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle);
 enum ice_status
 ice_sched_set_node_bw_lmt_per_tc(struct ice_port_info *pi, u32 id,
@@ -193,18 +183,4 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw);
 enum ice_status
 ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
 			     u8 priority);
-enum ice_status
-ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node,
-			    enum ice_rl_type rl_type, u8 bw_alloc);
-enum ice_status
-ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc);
-enum ice_status
-ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc);
-enum ice_status
-ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
-			  u8 tc);
-enum ice_status
-ice_sched_del_rl_profile(struct ice_hw *hw,
-			 struct ice_aqc_rl_profile_info *rl_info);
-void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi);
 #endif /* _ICE_SCHED_H_ */
Signature · 1 line
2.13.6
author
#64 lore raw

PATCH v2 19/37 net/ice/base: enable VSI queue context

In reply to Qi Zhang

The patch added to retrieve the queue context and update the queue handle for lan queues.

---
 drivers/net/ice/base/ice_common.c | 60 ++++++++++++++++++++++++++++++++++++---
 drivers/net/ice/base/ice_common.h | 11 +++----
 drivers/net/ice/ice_rxtx.c        | 11 +++++--
 3 files changed, 70 insertions(+), 12 deletions(-)
drivers/net/ice/base/ice_common.c +56 -4
index e0fe06e9c..f5cbd47c3 100644
@@ -3512,10 +3512,35 @@ ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info)
 }
 
 /**
+ * ice_get_lan_q_ctx - get the LAN queue context for the given VSI and TC
+ * @hw: pointer to the HW struct
+ * @vsi_handle: software VSI handle
+ * @tc: TC number
+ * @q_handle: software queue handle
+ */
+static struct ice_q_ctx *
+ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle)
+{
+	struct ice_vsi_ctx *vsi;
+	struct ice_q_ctx *q_ctx;
+
+	vsi = ice_get_vsi_ctx(hw, vsi_handle);
+	if (!vsi)
+		return NULL;
+	if (q_handle >= vsi->num_lan_q_entries[tc])
+		return NULL;
+	if (!vsi->lan_q_ctx[tc])
+		return NULL;
+	q_ctx = vsi->lan_q_ctx[tc];
+	return &q_ctx[q_handle];
+}
+
+/**
  * ice_ena_vsi_txq
  * @pi: port information structure
  * @vsi_handle: software VSI handle
  * @tc: TC number
+ * @q_handle: software queue handle
  * @num_qgrps: Number of added queue groups
  * @buf: list of queue groups to be added
  * @buf_size: size of buffer for indirect command
@@ -3524,12 +3549,13 @@ ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info)
  * This function adds one LAN queue
  */
 enum ice_status
-ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
-		struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
+ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
+		u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
 		struct ice_sq_cd *cd)
 {
 	struct ice_aqc_txsched_elem_data node = { 0 };
 	struct ice_sched_node *parent;
+	struct ice_q_ctx *q_ctx;
 	enum ice_status status;
 	struct ice_hw *hw;
 
@@ -3546,6 +3572,14 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
 
 	ice_acquire_lock(&pi->sched_lock);
 
+	q_ctx = ice_get_lan_q_ctx(hw, vsi_handle, tc, q_handle);
+	if (!q_ctx) {
+		ice_debug(hw, ICE_DBG_SCHED, "Enaq: invalid queue handle %d\n",
+			  q_handle);
+		status = ICE_ERR_PARAM;
+		goto ena_txq_exit;
+	}
+
 	/* find a parent node */
 	parent = ice_sched_get_free_qparent(pi, vsi_handle, tc,
 					    ICE_SCHED_NODE_OWNER_LAN);
@@ -3580,6 +3614,7 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
 
 	node.node_teid = buf->txqs[0].q_teid;
 	node.data.elem_type = ICE_AQC_ELEM_TYPE_LEAF;
+	q_ctx->q_handle = q_handle;
 
 	/* add a leaf node into schduler tree queue layer */
 	status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node);
@@ -3592,7 +3627,10 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
 /**
  * ice_dis_vsi_txq
  * @pi: port information structure
+ * @vsi_handle: software VSI handle
+ * @tc: TC number
  * @num_queues: number of queues
+ * @q_handles: pointer to software queue handle array
  * @q_ids: pointer to the q_id array
  * @q_teids: pointer to queue node teids
  * @rst_src: if called due to reset, specifies the reset source
@@ -3602,12 +3640,14 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
  * This function removes queues and their corresponding nodes in SW DB
  */
 enum ice_status
-ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
-		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
+ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
+		u16 *q_handles, u16 *q_ids, u32 *q_teids,
+		enum ice_disq_rst_src rst_src, u16 vmvf_num,
 		struct ice_sq_cd *cd)
 {
 	enum ice_status status = ICE_ERR_DOES_NOT_EXIST;
 	struct ice_aqc_dis_txq_item qg_list;
+	struct ice_q_ctx *q_ctx;
 	u16 i;
 
 	if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
@@ -3630,6 +3670,17 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		node = ice_sched_find_node_by_teid(pi->root, q_teids[i]);
 		if (!node)
 			continue;
+		q_ctx = ice_get_lan_q_ctx(pi->hw, vsi_handle, tc, q_handles[i]);
+		if (!q_ctx) {
+			ice_debug(pi->hw, ICE_DBG_SCHED, "invalid queue handle%d\n",
+				  q_handles[i]);
+			continue;
+		}
+		if (q_ctx->q_handle != q_handles[i]) {
+			ice_debug(pi->hw, ICE_DBG_SCHED, "Err:handles %d %d\n",
+				  q_ctx->q_handle, q_handles[i]);
+			continue;
+		}
 		qg_list.parent_teid = node->info.parent_teid;
 		qg_list.num_qs = 1;
 		qg_list.q_id[0] = CPU_TO_LE16(q_ids[i]);
@@ -3640,6 +3691,7 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
 		if (status != ICE_SUCCESS)
 			break;
 		ice_free_sched_node(pi, node);
+		q_ctx->q_handle = ICE_INVAL_Q_HANDLE;
 	}
 	ice_release_lock(&pi->sched_lock);
 	return status;
drivers/net/ice/base/ice_common.h +6 -5
index 63f4a5ebe..72560fbbf 100644
@@ -157,15 +157,16 @@ ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 enum ice_status
 ice_get_ctx(u8 *src_ctx, u8 *dest_ctx, struct ice_ctx_ele *ce_info);
 enum ice_status
-ice_dis_vsi_txq(struct ice_port_info *pi, u8 num_queues, u16 *q_ids,
-		u32 *q_teids, enum ice_disq_rst_src rst_src, u16 vmvf_num,
-		struct ice_sq_cd *cmd_details);
+ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
+		u16 *q_handle, u16 *q_ids, u32 *q_teids,
+		enum ice_disq_rst_src rst_src, u16 vmvf_num,
+		struct ice_sq_cd *cd);
 enum ice_status
 ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap,
 		u16 *max_lanqs);
 enum ice_status
-ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps,
-		struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
+ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
+		u8 num_qgrps, struct ice_aqc_add_tx_qgrp *buf, u16 buf_size,
 		struct ice_sq_cd *cd);
 enum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
 void ice_replay_post(struct ice_hw *hw);
drivers/net/ice/ice_rxtx.c +8 -3
index c794ee861..b65bb4a51 100644
@@ -453,7 +453,8 @@ ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	/* Init the Tx tail register*/
 	ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
 
-	err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, 1, &txq_elem,
+	/* Fix me, we assume TC always 0 here */
+	err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, 0, 1, &txq_elem,
 			      sizeof(txq_elem), NULL);
 	if (err) {
 		PMD_DRV_LOG(ERR, "Failed to add lan txq");
@@ -528,9 +529,12 @@ ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct ice_tx_queue *txq;
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct ice_vsi *vsi = pf->main_vsi;
 	enum ice_status status;
 	uint16_t q_ids[1];
 	uint32_t q_teids[1];
+	uint16_t q_handle = 0;
 
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
 		PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
@@ -548,8 +552,9 @@ ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	q_ids[0] = txq->reg_idx;
 	q_teids[0] = txq->q_teid;
 
-	status = ice_dis_vsi_txq(hw->port_info, 1, q_ids, q_teids,
-				 ICE_NO_RESET, 0, NULL);
+	/* Fix me, we assume TC always 0 here */
+	status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
+				q_ids, q_teids, ICE_NO_RESET, 0, NULL);
 	if (status != ICE_SUCCESS) {
 		PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
 		return -EINVAL;
Signature · 1 line
2.13.6
author
#65 lore raw

PATCH v2 20/37 net/ice/base: ensure only valid bits are set

In reply to Qi Zhang

In the ice_aq_set_phy_cfg AQ command, the 16.4 bit is reserved. This patch will make sure that this bit will never be set to 1.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 1 +
 drivers/net/ice/base/ice_common.c     | 9 +++++++++
 2 files changed, 10 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +1 -0
index ca3d40c8b..70cd0604b 100644
@@ -1327,6 +1327,7 @@ struct ice_aqc_set_phy_cfg_data {
 	__le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */
 	__le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */
 	u8 caps;
+#define ICE_AQ_PHY_ENA_VALID_MASK	MAKEMASK(0xef, 0)
 #define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY	BIT(0)
 #define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY	BIT(1)
 #define ICE_AQ_PHY_ENA_LOW_POWER	BIT(2)
drivers/net/ice/base/ice_common.c +9 -0
index f5cbd47c3..1c381b5e2 100644
@@ -2351,6 +2351,15 @@ ice_aq_set_phy_cfg(struct ice_hw *hw, u8 lport,
 	if (!cfg)
 		return ICE_ERR_PARAM;
 
+	/* Ensure that only valid bits of cfg->caps can be turned on. */
+	if (cfg->caps & ~ICE_AQ_PHY_ENA_VALID_MASK) {
+		ice_debug(hw, ICE_DBG_PHY,
+			  "Invalid bit is set in ice_aqc_set_phy_cfg_data->caps : 0x%x\n",
+			  cfg->caps);
+
+		cfg->caps &= ICE_AQ_PHY_ENA_VALID_MASK;
+	}
+
 	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_phy_cfg);
 	desc.params.set_phy.lport_num = lport;
 	desc.flags |= CPU_TO_LE16(ICE_AQ_FLAG_RD);
Signature · 1 line
2.13.6
author
#66 lore raw

PATCH v2 21/37 net/ice/base: enhance get link status command

In reply to Qi Zhang

Extend the functionality of the admin queue command by including additional status and ID bits to improve link topology configuration.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ice/base/ice_adminq_cmd.h +6 -1
index 70cd0604b..cb1e1ca1a 100644
@@ -1399,7 +1399,12 @@ struct ice_aqc_get_link_status_data {
 #define ICE_AQ_LINK_TOPO_CONFLICT	BIT(0)
 #define ICE_AQ_LINK_MEDIA_CONFLICT	BIT(1)
 #define ICE_AQ_LINK_TOPO_CORRUPT	BIT(2)
-	u8 reserved1;
+#define ICE_AQ_LINK_TOPO_UNREACH_PRT	BIT(4)
+#define ICE_AQ_LINK_TOPO_UNDRUTIL_PRT	BIT(5)
+#define ICE_AQ_LINK_TOPO_UNDRUTIL_MEDIA	BIT(6)
+#define ICE_AQ_LINK_TOPO_UNSUPP_MEDIA	BIT(7)
+	u8 link_cfg_err;
+#define ICE_AQ_LINK_CFG_ERR		BIT(0)
 	u8 link_info;
 #define ICE_AQ_LINK_UP			BIT(0)	/* Link Status */
 #define ICE_AQ_LINK_FAULT		BIT(1)
Signature · 1 line
2.13.6
author
#67 lore raw

PATCH v2 22/37 net/ice/base: add RSS key related macro and structures

In reply to Qi Zhang

Add define for 52 byte RSS hash key size, and add struct ice_aqc_get_set_rss_keys comments regarding setting 40 bytes and 52 byte hash key.

---
 drivers/net/ice/base/ice_adminq_cmd.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/net/ice/base/ice_adminq_cmd.h +13 -0
index cb1e1ca1a..ed7dfae8c 100644
@@ -1593,7 +1593,20 @@ struct ice_aqc_get_set_rss_key {
 
 #define ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE	0x28
 #define ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE	0xC
+#define ICE_GET_SET_RSS_KEY_EXTEND_KEY_SIZE \
+				(ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE + \
+				 ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE)
 
+/**
+ * struct ice_aqc_get_set_rss_keys - Get/Set RSS hash key command buffer
+ * @standard_rss_key: 40 most significant bytes of hash key
+ * @extended_hash_key: 12 least significant bytes of hash key
+ *
+ * Set/Get 40 byte hash key using standard_rss_key field, and set
+ * extended_hash_key field to zero. Set/Get 52 byte hash key using
+ * standard_rss_key field for 40 most significant bytes and the
+ * extended_hash_key field for the 12 least significant bytes of hash key.
+ */
 struct ice_aqc_get_set_rss_keys {
 	u8 standard_rss_key[ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE];
 	u8 extended_hash_key[ICE_AQC_GET_SET_RSS_KEY_DATA_HASH_KEY_SIZE];
Signature · 1 line
2.13.6
author
#68 lore raw

PATCH v2 23/37 net/ice/base: do not write TCAM entries back

In reply to Qi Zhang

Profile TCAM entry removal is handled by the firmware when freeing the resource, so the driver does not need to write these default entries back with an update Package action.

This patch removes writing of the TCAM entry using Update Package command when removing it, since the entry has already been freed by firmware.

---
 drivers/net/ice/base/ice_flex_pipe.c | 41 +++++++++---------------------------
 drivers/net/ice/base/ice_flex_type.h |  2 --
 2 files changed, 10 insertions(+), 33 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +10 -31
index ff615f94f..900a19387 100644
@@ -3558,8 +3558,7 @@ ice_prof_bld_tcam(struct ice_hw *hw, enum ice_block blk,
 	struct ice_chs_chg *tmp;
 
 	LIST_FOR_EACH_ENTRY(tmp, chgs, ice_chs_chg, list_entry) {
-		if ((tmp->type == ICE_TCAM_ADD && tmp->add_tcam_idx) ||
-		    tmp->type == ICE_TCAM_REM) {
+		if (tmp->type == ICE_TCAM_ADD && tmp->add_tcam_idx) {
 			struct ice_prof_id_section *p;
 			u32 id;
 
@@ -3689,7 +3688,6 @@ ice_upd_prof_hw(struct ice_hw *hw, enum ice_block blk,
 				es++;
 			break;
 		case ICE_TCAM_ADD:
-		case ICE_TCAM_REM:
 			tcam++;
 			break;
 		case ICE_VSIG_ADD:
@@ -3962,46 +3960,27 @@ ice_rel_tcam_idx(struct ice_hw *hw, enum ice_block blk, u16 idx)
  * ice_rem_prof_id - remove one profile from a VSIG
  * @hw: pointer to the HW struct
  * @blk: hardware block
- * @vsig: VSIG to remove the profile from
  * @prof: pointer to profile structure to remove
- * @chg: pointer to list to record changes
  */
 static enum ice_status
-ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk, u16 vsig,
-		struct ice_vsig_prof *prof, struct LIST_HEAD_TYPE *chg)
+ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk,
+		struct ice_vsig_prof *prof)
 {
 	enum ice_status status;
-	struct ice_chs_chg *p;
 	u16 i;
 
 	for (i = 0; i < prof->tcam_count; i++) {
-		p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
-		if (!p)
-			goto err_ice_rem_prof_id;
-
-		p->type = ICE_TCAM_REM;
-		p->vsig = vsig;
-		p->prof_id = prof->tcam[i].prof_id;
-		p->tcam_idx = prof->tcam[i].tcam_idx;
-
-		p->ptg = prof->tcam[i].ptg;
 		prof->tcam[i].in_use = false;
-		p->orig_ent = hw->blk[blk].prof.t[p->tcam_idx];
-		status = ice_rel_tcam_idx(hw, blk, p->tcam_idx);
+		status = ice_rel_tcam_idx(hw, blk, prof->tcam[i].tcam_idx);
 		if (!status)
-			status = ice_prof_dec_ref(hw, blk, p->prof_id);
-
-		LIST_ADD(&p->list_entry, chg);
+			status = ice_prof_dec_ref(hw, blk,
+						  prof->tcam[i].prof_id);
 
 		if (status)
-			goto err_ice_rem_prof_id;
+			return ICE_ERR_HW_TABLE;
 	}
 
 	return ICE_SUCCESS;
-
-err_ice_rem_prof_id:
-	/* caller will clean up the change list */
-	return ICE_ERR_NO_MEMORY;
 }
 
 /**
@@ -4024,9 +4003,9 @@ ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
 	LIST_FOR_EACH_ENTRY_SAFE(d, t,
 				 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
 				 ice_vsig_prof, list) {
-		status = ice_rem_prof_id(hw, blk, vsig, d, chg);
+		status = ice_rem_prof_id(hw, blk, d);
 		if (status)
-			goto err_ice_rem_vsig;
+			return status;
 
 		LIST_DEL(&d->list);
 		ice_free(hw, d);
@@ -4090,7 +4069,7 @@ ice_rem_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 				/* this is the last profile, remove the VSIG */
 				return ice_rem_vsig(hw, blk, vsig, chg);
 
-			status = ice_rem_prof_id(hw, blk, vsig, p, chg);
+			status = ice_rem_prof_id(hw, blk, p);
 			if (!status) {
 				LIST_DEL(&p->list);
 				ice_free(hw, p);
drivers/net/ice/base/ice_flex_type.h +0 -2
index aed23a067..1bb865896 100644
@@ -676,7 +676,6 @@ enum ice_chg_type {
 	ICE_TCAM_NONE = 0,
 	ICE_PTG_ES_ADD,
 	ICE_TCAM_ADD,
-	ICE_TCAM_REM,
 	ICE_VSIG_ADD,
 	ICE_VSIG_REM,
 	ICE_VSI_MOVE,
@@ -697,7 +696,6 @@ struct ice_chs_chg {
 	u16 vsig;
 	u16 orig_vsig;
 	u16 tcam_idx;
-	struct ice_prof_tcam_entry orig_ent;
 };
 
 #define ICE_FLOW_PTYPE_MAX		ICE_XLT1_CNT
Signature · 1 line
2.13.6
author
#69 lore raw

PATCH v2 24/37 net/ice/base: remove local VSIG allocations

In reply to Qi Zhang

If allocating a VSI to a VSIG fails the local allocations made for VSIG profiles and change-lists will not be removed. Adding calls to free these entries on error in VSIG management calls.

---
 drivers/net/ice/base/ice_flex_pipe.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +15 -5
index 900a19387..887609204 100644
@@ -4523,8 +4523,10 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 		/* allocate the TCAM entry index */
 		status = ice_alloc_tcam_ent(hw, blk, &tcam_idx);
-		if (status)
+		if (status) {
+			ice_free(hw, p);
 			goto err_ice_add_prof_id_vsig;
+		}
 
 		t->tcam[i].ptg = ptg;
 		t->tcam[i].prof_id = map->prof_id;
@@ -4563,6 +4565,7 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 
 err_ice_add_prof_id_vsig:
 	/* let caller clean up the change list */
+	ice_free(hw, t);
 	return ICE_ERR_NO_MEMORY;
 }
 
@@ -4587,16 +4590,18 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 		return ICE_ERR_NO_MEMORY;
 
 	new_vsig = ice_vsig_alloc(hw, blk);
-	if (!new_vsig)
-		return ICE_ERR_HW_TABLE;
+	if (!new_vsig) {
+		status = ICE_ERR_HW_TABLE;
+		goto err_ice_create_prof_id_vsig;
+	}
 
 	status = ice_move_vsi(hw, blk, vsi, new_vsig, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, chg);
 	if (status)
-		return status;
+		goto err_ice_create_prof_id_vsig;
 
 	p->type = ICE_VSIG_ADD;
 	p->vsi = vsi;
@@ -4606,6 +4611,11 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl,
 	LIST_ADD(&p->list_entry, chg);
 
 	return ICE_SUCCESS;
+
+err_ice_create_prof_id_vsig:
+	/* let caller clean up the change list */
+	ice_free(hw, p);
+	return status;
 }
 
 /**
Signature · 1 line
2.13.6
author
#70 lore raw

PATCH v2 25/37 net/ice/base: minor fix

In reply to Qi Zhang

1. Fix some problems with filling the HW tables.
2. Fix a logic error in ice_rem_prof_from_list.

Fixes 51d04e4933e3 ("net/ice/base: add flexible pipeline module")
---
 drivers/net/ice/base/ice_flex_pipe.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +15 -3
index 887609204..1dd121b28 100644
@@ -2935,9 +2935,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 
 	while (sect) {
 		switch (sid) {
+		case ICE_SID_XLT1_SW:
 		case ICE_SID_XLT1_FD:
 		case ICE_SID_XLT1_RSS:
 		case ICE_SID_XLT1_ACL:
+		case ICE_SID_XLT1_PE:
 			xlt1 = (struct ice_xlt1_section *)sect;
 			src = xlt1->value;
 			sect_len = LE16_TO_CPU(xlt1->count) *
@@ -2946,9 +2948,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].xlt1.count *
 				sizeof(*hw->blk[block_id].xlt1.t);
 			break;
+		case ICE_SID_XLT2_SW:
 		case ICE_SID_XLT2_FD:
 		case ICE_SID_XLT2_RSS:
 		case ICE_SID_XLT2_ACL:
+		case ICE_SID_XLT2_PE:
 			xlt2 = (struct ice_xlt2_section *)sect;
 			src = (u8 *)xlt2->value;
 			sect_len = LE16_TO_CPU(xlt2->count) *
@@ -2957,9 +2961,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].xlt2.count *
 				sizeof(*hw->blk[block_id].xlt2.t);
 			break;
+		case ICE_SID_PROFID_TCAM_SW:
 		case ICE_SID_PROFID_TCAM_FD:
 		case ICE_SID_PROFID_TCAM_RSS:
 		case ICE_SID_PROFID_TCAM_ACL:
+		case ICE_SID_PROFID_TCAM_PE:
 			pid = (struct ice_prof_id_section *)sect;
 			src = (u8 *)pid->entry;
 			sect_len = LE16_TO_CPU(pid->count) *
@@ -2968,9 +2974,11 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].prof.count *
 				sizeof(*hw->blk[block_id].prof.t);
 			break;
+		case ICE_SID_PROFID_REDIR_SW:
 		case ICE_SID_PROFID_REDIR_FD:
 		case ICE_SID_PROFID_REDIR_RSS:
 		case ICE_SID_PROFID_REDIR_ACL:
+		case ICE_SID_PROFID_REDIR_PE:
 			pr = (struct ice_prof_redir_section *)sect;
 			src = pr->redir_value;
 			sect_len = LE16_TO_CPU(pr->count) *
@@ -2979,15 +2987,19 @@ static void ice_fill_tbl(struct ice_hw *hw, enum ice_block block_id, u32 sid)
 			dst_len = hw->blk[block_id].prof_redir.count *
 				sizeof(*hw->blk[block_id].prof_redir.t);
 			break;
+		case ICE_SID_FLD_VEC_SW:
 		case ICE_SID_FLD_VEC_FD:
 		case ICE_SID_FLD_VEC_RSS:
 		case ICE_SID_FLD_VEC_ACL:
+		case ICE_SID_FLD_VEC_PE:
 			es = (struct ice_sw_fv_section *)sect;
 			src = (u8 *)es->fv;
 			sect_len = LE16_TO_CPU(es->count) *
-				sizeof(*hw->blk[block_id].prof_redir.t);
+				hw->blk[block_id].es.fvw *
+				sizeof(*hw->blk[block_id].es.t);
 			dst = (u8 *)hw->blk[block_id].es.t;
 			dst_len = hw->blk[block_id].es.count *
+				hw->blk[block_id].es.fvw *
 				sizeof(*hw->blk[block_id].es.t);
 			break;
 		default:
@@ -4964,8 +4976,8 @@ ice_rem_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl)
 				if (status)
 					goto err_ice_rem_prof_id_flow;
 
-			} else if (ice_find_dup_props_vsig(hw, blk, &copy,
-							   &vsig)) {
+			} else if (!ice_find_dup_props_vsig(hw, blk, &copy,
+							    &vsig)) {
 				/* found an exact match */
 				/* add or move VSI to the VSIG that matches */
 				/* Search for a VSIG with a matching profile
Signature · 1 line
2.13.6
author
#71 lore raw

PATCH v2 26/37 net/ice/base: update copyright time

In reply to Qi Zhang

Update copyright time to 2019.

---
 drivers/net/ice/base/ice_adminq_cmd.h    | 2 +-
 drivers/net/ice/base/ice_alloc.h         | 2 +-
 drivers/net/ice/base/ice_common.c        | 2 +-
 drivers/net/ice/base/ice_common.h        | 2 +-
 drivers/net/ice/base/ice_controlq.c      | 2 +-
 drivers/net/ice/base/ice_controlq.h      | 2 +-
 drivers/net/ice/base/ice_devids.h        | 2 +-
 drivers/net/ice/base/ice_flex_type.h     | 2 +-
 drivers/net/ice/base/ice_flow.h          | 2 +-
 drivers/net/ice/base/ice_hw_autogen.h    | 2 +-
 drivers/net/ice/base/ice_lan_tx_rx.h     | 2 +-
 drivers/net/ice/base/ice_nvm.c           | 2 +-
 drivers/net/ice/base/ice_protocol_type.h | 2 +-
 drivers/net/ice/base/ice_sbq_cmd.h       | 2 +-
 drivers/net/ice/base/ice_sched.c         | 2 +-
 drivers/net/ice/base/ice_sched.h         | 2 +-
 drivers/net/ice/base/ice_status.h        | 2 +-
 drivers/net/ice/base/ice_switch.c        | 2 +-
 drivers/net/ice/base/ice_switch.h        | 2 +-
 drivers/net/ice/base/ice_type.h          | 2 +-
 20 files changed, 20 insertions(+), 20 deletions(-)
drivers/net/ice/base/ice_adminq_cmd.h +1 -1
index ed7dfae8c..81a331b41 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_ADMINQ_CMD_H_
drivers/net/ice/base/ice_alloc.h +1 -1
index 78831045b..cf823a2c2 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_ALLOC_H_
drivers/net/ice/base/ice_common.c +1 -1
index 1c381b5e2..ae0e7fc5f 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_common.h"
drivers/net/ice/base/ice_common.h +1 -1
index 72560fbbf..cc7a77747 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_COMMON_H_
drivers/net/ice/base/ice_controlq.c +1 -1
index 1c0830cec..f3404023a 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_common.h"
drivers/net/ice/base/ice_controlq.h +1 -1
index db2db9389..182db6754 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_CONTROLQ_H_
drivers/net/ice/base/ice_devids.h +1 -1
index 87f17ab91..5f1ac0422 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_DEVIDS_H_
drivers/net/ice/base/ice_flex_type.h +1 -1
index 1bb865896..951c2051f 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_FLEX_TYPE_H_
drivers/net/ice/base/ice_flow.h +1 -1
index 3db10cd6f..bad925c8c 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_FLOW_H_
drivers/net/ice/base/ice_hw_autogen.h +1 -1
index 8c79891ad..e63e41133 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 /* Machine-generated file; do not edit */
drivers/net/ice/base/ice_lan_tx_rx.h +1 -1
index b1963b5eb..8c9902994 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_LAN_TX_RX_H_
drivers/net/ice/base/ice_nvm.c +1 -1
index 8d3d0b0ed..b770abfd0 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_common.h"
drivers/net/ice/base/ice_protocol_type.h +1 -1
index f96964d86..6b3bd6542 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_PROTOCOL_TYPE_H_
drivers/net/ice/base/ice_sbq_cmd.h +1 -1
index 6dff37871..70a019292 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_SBQ_CMD_H_
drivers/net/ice/base/ice_sched.c +1 -1
index 2dd9f6f6c..8773e62a9 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_sched.h"
drivers/net/ice/base/ice_sched.h +1 -1
index 09de765ff..92377a82e 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_SCHED_H_
drivers/net/ice/base/ice_status.h +1 -1
index 898bfa6d8..cd561b0a4 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_STATUS_H_
drivers/net/ice/base/ice_switch.c +1 -1
index e47c1d845..a1c29d606 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #include "ice_switch.h"
drivers/net/ice/base/ice_switch.h +1 -1
index 3cc2c10e8..13525d8d0 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_SWITCH_H_
drivers/net/ice/base/ice_type.h +1 -1
index 25d64477f..90736faa1 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2019
  */
 
 #ifndef _ICE_TYPE_H_
Signature · 1 line
2.13.6
author
#72 lore raw

PATCH v2 27/37 net/ice/base: fix static analysis reported issues

In reply to Qi Zhang

Klocwork points out some code is unreachable in ice_get_itr_intrl_gran and ice_ptg_find_ptype.
The patch removed the unreachable code and resolved the static analysis reported issues.

Fixes 51d04e4933e3 ("net/ice/base: add flexible pipeline module")
Fixes 453d087ccaff ("net/ice/base: add common functions")
---
 drivers/net/ice/base/ice_common.c    | 12 ++----------
 drivers/net/ice/base/ice_flex_pipe.c |  7 +------
 2 files changed, 3 insertions(+), 16 deletions(-)
drivers/net/ice/base/ice_common.c +2 -10
index ae0e7fc5f..2362dd774 100644
@@ -741,7 +741,7 @@ void ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf)
  * Determines the itr/intrl granularities based on the maximum aggregate
  * bandwidth according to the device's configuration during power-on.
  */
-static enum ice_status ice_get_itr_intrl_gran(struct ice_hw *hw)
+static void ice_get_itr_intrl_gran(struct ice_hw *hw)
 {
 	u8 max_agg_bw = (rd32(hw, GL_PWR_MODE_CTL) &
 			 GL_PWR_MODE_CTL_CAR_MAX_BW_M) >>
@@ -758,13 +758,7 @@ static enum ice_status ice_get_itr_intrl_gran(struct ice_hw *hw)
 		hw->itr_gran = ICE_ITR_GRAN_MAX_25;
 		hw->intrl_gran = ICE_INTRL_GRAN_MAX_25;
 		break;
-	default:
-		ice_debug(hw, ICE_DBG_INIT,
-			  "Failed to determine itr/intrl granularity\n");
-		return ICE_ERR_CFG;
 	}
-
-	return ICE_SUCCESS;
 }
 
 /**
@@ -795,9 +789,7 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 	if (status)
 		return status;
 
-	status = ice_get_itr_intrl_gran(hw);
-	if (status)
-		return status;
+	ice_get_itr_intrl_gran(hw);
 
 
 	status = ice_init_all_ctrlq(hw);
drivers/net/ice/base/ice_flex_pipe.c +1 -6
index 1dd121b28..525378079 100644
@@ -4288,17 +4288,12 @@ ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk,
 	p->tcam_count = map->ptype_count;
 
 	for (i = 0; i < map->ptype_count; i++) {
-		enum ice_status status;
 		u8 ptg;
 
 		p->tcam[i].prof_id = map->prof_id;
 		p->tcam[i].tcam_idx = ICE_INVALID_TCAM;
 
-		status = ice_ptg_find_ptype(hw, blk, map->ptype[i], &ptg);
-		if (status) {
-			ice_free(hw, p);
-			return status;
-		}
+		ice_ptg_find_ptype(hw, blk, map->ptype[i], &ptg);
 
 		p->tcam[i].ptg = ptg;
 	}
Signature · 1 line
2.13.6
author
#73 lore raw

PATCH v2 28/37 net/ice/base: return config error without queue to disable

In reply to Qi Zhang

If there is no queue to disable, return appropriate configuration error earlier without acquiring the lock.

---
 drivers/net/ice/base/ice_common.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ice/base/ice_common.c +10 -7
index 2362dd774..c35a2f91d 100644
@@ -3654,14 +3654,17 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
 	if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
 		return ICE_ERR_CFG;
 
-	/* if queue is disabled already yet the disable queue command has to be
-	 * sent to complete the VF reset, then call ice_aq_dis_lan_txq without
-	 * any queue information
-	 */
 
-	if (!num_queues && rst_src)
-		return ice_aq_dis_lan_txq(pi->hw, 0, NULL, 0, rst_src, vmvf_num,
-					  NULL);
+	if (!num_queues) {
+		/* if queue is disabled already yet the disable queue command
+		 * has to be sent to complete the VF reset, then call
+		 * ice_aq_dis_lan_txq without any queue information
+		 */
+		if (rst_src)
+			return ice_aq_dis_lan_txq(pi->hw, 0, NULL, 0, rst_src,
+						  vmvf_num, NULL);
+		return ICE_ERR_CFG;
+	}
 
 	ice_acquire_lock(&pi->sched_lock);
 
Signature · 1 line
2.13.6
author
#74 lore raw

PATCH v2 29/37 net/ice/base: add function to check FW recovery mode

In reply to Qi Zhang

Code added to check the FW recovery mode. This function will be used by the drivers during init to check whether the FW is in recovery mode or not. If FW is in recovery mode then the drivers need to run in a recovery mode where it can allow only limited operations. Link should be down, allow only certain AQ commands etc.

---
 drivers/net/ice/base/ice_common.c | 15 +++++++++++++++
 drivers/net/ice/base/ice_common.h |  8 ++++++++
 2 files changed, 23 insertions(+)
drivers/net/ice/base/ice_common.c +15 -0
index c35a2f91d..2ebf95eed 100644
@@ -3915,3 +3915,18 @@ ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
 		ice_debug(hw, ICE_DBG_SCHED, "query element failed\n");
 	return status;
 }
+
+/**
+ * ice_is_fw_in_rec_mode
+ * @hw: pointer to the HW struct
+ *
+ * This function returns true if fw is in recovery mode
+ */
+bool ice_is_fw_in_rec_mode(struct ice_hw *hw)
+{
+	u32 reg;
+
+	/* check the current FW mode */
+	reg = rd32(hw, GL_MNG_FWSM);
+	return (reg & GL_MNG_FWSM_FW_MODES_M) > ICE_FW_MODE_DBG;
+}
drivers/net/ice/base/ice_common.h +8 -0
index cc7a77747..9665f3204 100644
@@ -10,6 +10,13 @@
 #include "ice_flex_pipe.h"
 #include "ice_switch.h"
 
+enum ice_fw_modes {
+	ICE_FW_MODE_NORMAL,
+	ICE_FW_MODE_DBG,
+	ICE_FW_MODE_REC,
+	ICE_FW_MODE_DBG_REC
+};
+
 enum ice_status ice_nvm_validate_checksum(struct ice_hw *hw);
 
 void
@@ -188,4 +195,5 @@ ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
 enum ice_status
 ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
 		     struct ice_aqc_get_elem *buf);
+bool ice_is_fw_in_rec_mode(struct ice_hw *hw);
 #endif /* _ICE_COMMON_H_ */
Signature · 1 line
2.13.6
author
#75 lore raw

PATCH v2 30/37 net/ice/base: change profile id reference counting

In reply to Qi Zhang

Improved the profile reference counting, by moving it from being based on how many TCAM entries using the profile to how many profile map entries are using the profile.

---
 drivers/net/ice/base/ice_flex_pipe.c | 70 ++++++++++++++++++++----------------
 drivers/net/ice/base/ice_flex_type.h |  1 +
 2 files changed, 41 insertions(+), 30 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +40 -30
index 525378079..99108d81c 100644
@@ -2816,6 +2816,30 @@ ice_prof_inc_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
 }
 
 /**
+ * ice_write_es - write an extraction sequence to hardware
+ * @hw: pointer to the HW struct
+ * @blk: the block in which to write the extraction sequence
+ * @prof_id: the profile ID to write
+ * @fv: pointer to the extraction sequence to write - NULL to clear extraction
+ */
+static void
+ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id,
+	     struct ice_fv_word *fv)
+{
+	u16 off;
+
+	off = prof_id * hw->blk[blk].es.fvw;
+	if (!fv) {
+		ice_memset(&hw->blk[blk].es.t[off], 0, hw->blk[blk].es.fvw *
+			   sizeof(*fv), ICE_NONDMA_MEM);
+		hw->blk[blk].es.written[prof_id] = false;
+	} else {
+		ice_memcpy(&hw->blk[blk].es.t[off], fv, hw->blk[blk].es.fvw *
+			   sizeof(*fv), ICE_NONDMA_TO_NONDMA);
+	}
+}
+
+/**
  * ice_prof_dec_ref - decrement reference count for profile
  * @hw: pointer to the HW struct
  * @blk: the block from which to free the profile ID
@@ -2828,31 +2852,15 @@ ice_prof_dec_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id)
 		return ICE_ERR_PARAM;
 
 	if (hw->blk[blk].es.ref_count[prof_id] > 0) {
-		if (!--hw->blk[blk].es.ref_count[prof_id])
+		if (!--hw->blk[blk].es.ref_count[prof_id]) {
+			ice_write_es(hw, blk, prof_id, NULL);
 			return ice_free_prof_id(hw, blk, prof_id);
+		}
 	}
 
 	return ICE_SUCCESS;
 }
 
-/**
- * ice_write_es - write an extraction sequence to hardware
- * @hw: pointer to the HW struct
- * @blk: the block in which to write the extraction sequence
- * @prof_id: the profile ID to write
- * @fv: pointer to the extraction sequence to write
- */
-static void
-ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id,
-	     struct ice_fv_word *fv)
-{
-	u16 off;
-
-	off = prof_id * hw->blk[blk].es.fvw;
-	ice_memcpy(&hw->blk[blk].es.t[off], fv, hw->blk[blk].es.fvw * 2,
-		   ICE_NONDMA_TO_NONDMA);
-}
-
 /* Block / table section IDs */
 static const u32 ice_blk_sids[ICE_BLK_COUNT][ICE_SID_OFF_COUNT] = {
 	/* SWITCH */
@@ -3140,6 +3148,7 @@ void ice_free_hw_tbls(struct ice_hw *hw)
 
 		ice_free(hw, hw->blk[i].es.resource_used_hack);
 		ice_free(hw, hw->blk[i].prof.resource_used_hack);
+		ice_free(hw, hw->blk[i].es.written);
 	}
 
 	ice_memset(hw->blk, 0, sizeof(hw->blk), ICE_NONDMA_MEM);
@@ -3309,6 +3318,9 @@ enum ice_status ice_init_hw_tbls(struct ice_hw *hw)
 		es->ref_count = (u16 *)
 			ice_calloc(hw, es->count, sizeof(*es->ref_count));
 
+		es->written = (u8 *)
+			ice_calloc(hw, es->count, sizeof(*es->written));
+
 		if (!es->ref_count)
 			goto err;
 
@@ -3805,6 +3817,8 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[],
 		ice_write_es(hw, blk, prof_id, es);
 	}
 
+	ice_prof_inc_ref(hw, blk, prof_id);
+
 	/* add profile info */
 
 	prof = (struct ice_prof_map *)ice_malloc(hw, sizeof(*prof));
@@ -3984,10 +3998,6 @@ ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk,
 	for (i = 0; i < prof->tcam_count; i++) {
 		prof->tcam[i].in_use = false;
 		status = ice_rel_tcam_idx(hw, blk, prof->tcam[i].tcam_idx);
-		if (!status)
-			status = ice_prof_dec_ref(hw, blk,
-						  prof->tcam[i].prof_id);
-
 		if (status)
 			return ICE_ERR_HW_TABLE;
 	}
@@ -4159,6 +4169,9 @@ enum ice_status ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id)
 	status = ice_rem_flow_all(hw, blk, pmap->profile_cookie);
 	if (status)
 		return status;
+	/* dereference profile, and possibly remove */
+	ice_prof_dec_ref(hw, blk, pmap->prof_id);
+
 	LIST_DEL(&pmap->list);
 	ice_free(hw, pmap);
 
@@ -4194,7 +4207,7 @@ ice_get_prof_ptgs(struct ice_hw *hw, enum ice_block blk, u64 hdl,
 		if (status)
 			goto err_ice_get_prof_ptgs;
 
-		if (add || !hw->blk[blk].es.ref_count[map->prof_id]) {
+		if (add || !hw->blk[blk].es.written[map->prof_id]) {
 			/* add PTG to change list */
 			p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
 			if (!p)
@@ -4205,9 +4218,11 @@ ice_get_prof_ptgs(struct ice_hw *hw, enum ice_block blk, u64 hdl,
 			p->ptg = ptg;
 			p->add_ptg = add;
 
-			p->add_prof = !hw->blk[blk].es.ref_count[map->prof_id];
+			p->add_prof = !hw->blk[blk].es.written[map->prof_id];
 			p->prof_id = map->prof_id;
 
+			hw->blk[blk].es.written[map->prof_id] = true;
+
 			LIST_ADD(&p->list_entry, chg);
 		}
 	}
@@ -4555,11 +4570,6 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl,
 		if (status)
 			goto err_ice_add_prof_id_vsig;
 
-		/* this increments the reference count of how many TCAM entries
-		 * are using this HW profile ID
-		 */
-		status = ice_prof_inc_ref(hw, blk, t->tcam[i].prof_id);
-
 		/* log change */
 		LIST_ADD(&p->list_entry, chg);
 	}
drivers/net/ice/base/ice_flex_type.h +1 -0
index 951c2051f..365f33390 100644
@@ -497,6 +497,7 @@ struct ice_es {
 	u16 count;
 	u16 fvw;
 	u16 *ref_count;
+	u8 *written;
 	u8 reverse; /* set to true to reverse FV order */
 	struct LIST_HEAD_TYPE prof_map;
 	struct ice_fv_word *t;
Signature · 1 line
2.13.6
author
#76 lore raw

PATCH v2 31/37 net/ice/base: add DCB support

In reply to Qi Zhang

Add module to support DCB related features.

---
 drivers/net/ice/Makefile              |    1 +
 drivers/net/ice/base/ice_adminq_cmd.h |  243 ++++++
 drivers/net/ice/base/ice_common.c     |   12 +
 drivers/net/ice/base/ice_dcb.c        | 1393 +++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_dcb.h        |  223 ++++++
 drivers/net/ice/base/ice_status.h     |    1 +
 drivers/net/ice/base/ice_type.h       |   14 +-
 drivers/net/ice/base/meson.build      |    1 +
 8 files changed, 1884 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_dcb.c
 create mode 100644 drivers/net/ice/base/ice_dcb.h
drivers/net/ice/Makefile +1 -0
index 61846cae2..89d21334e 100644
@@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_switch.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_nvm.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flex_pipe.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcb.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_rxtx.c
drivers/net/ice/base/ice_adminq_cmd.h +243 -0

301 lines not on this page · raw message

drivers/net/ice/base/ice_common.c +12 -0
index 2ebf95eed..202592710 100644
@@ -1930,6 +1930,18 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
 					  number);
 			}
 			break;
+		case ICE_AQC_CAPS_DCB:
+			caps->dcb = (number == 1);
+			caps->active_tc_bitmap = logical_id;
+			caps->maxtc = phys_id;
+			ice_debug(hw, ICE_DBG_INIT,
+				  "HW caps: DCB = %d\n", caps->dcb);
+			ice_debug(hw, ICE_DBG_INIT,
+				  "HW caps: Active TC bitmap = %d\n",
+				  caps->active_tc_bitmap);
+			ice_debug(hw, ICE_DBG_INIT,
+				  "HW caps: TC Max = %d\n", caps->maxtc);
+			break;
 		case ICE_AQC_CAPS_RSS:
 			caps->rss_table_size = number;
 			caps->rss_table_entry_width = logical_id;
drivers/net/ice/base/ice_dcb.c new file +1393 -0

1,393 lines not on this page · raw message

drivers/net/ice/base/ice_dcb.h new file +223 -0

223 lines not on this page · raw message

drivers/net/ice/base/ice_status.h +1 -0
index cd561b0a4..ac120fa30 100644
@@ -13,6 +13,7 @@ enum ice_status {
 	ICE_ERR_PARAM				= -1,
 	ICE_ERR_NOT_IMPL			= -2,
 	ICE_ERR_NOT_READY			= -3,
+	ICE_ERR_NOT_SUPPORTED			= -4,
 	ICE_ERR_BAD_PTR				= -5,
 	ICE_ERR_INVAL_SIZE			= -6,
 	ICE_ERR_DEVICE_NOT_SUPPORTED		= -8,
drivers/net/ice/base/ice_type.h +10 -4
index 90736faa1..6a08b3d28 100644
@@ -240,6 +240,9 @@ struct ice_hw_common_caps {
 
 	u32 os2bmc;
 	u32 valid_functions;
+	/* DCB capabilities */
+	u32 active_tc_bitmap;
+	u32 maxtc;
 
 	/* RSS related capabilities */
 	u32 rss_table_size;		/* 512 for PFs and 64 for VFs */
@@ -276,6 +279,7 @@ struct ice_hw_common_caps {
 	u8 evb_802_1_qbg;		/* Edge Virtual Bridging */
 	u8 evb_802_1_qbh;		/* Bridge Port Extension */
 
+	u8 dcb;
 	u8 iscsi;
 	u8 mgmt_cem;
 
@@ -527,7 +531,6 @@ struct ice_sched_vsi_info {
 	struct ice_bw_type_info bw_t_info[ICE_MAX_TRAFFIC_CLASS];
 };
 
-#if !defined(NO_DCB_SUPPORT) || defined(ADQ_SUPPORT)
 /* CEE or IEEE 802.1Qaz ETS Configuration data */
 struct ice_dcb_ets_cfg {
 	u8 willing;
@@ -580,7 +583,6 @@ struct ice_dcbx_cfg {
 	u8 app_mode;
 #define ICE_DCBX_APPS_NON_WILLING	0x1
 };
-#endif /* !NO_DCB_SUPPORT || ADQ_SUPPORT */
 
 struct ice_port_info {
 	struct ice_sched_node *root;	/* Root Node per Port */
@@ -601,9 +603,13 @@ struct ice_port_info {
 	struct ice_lock sched_lock;	/* protect access to TXSched tree */
 	/* List contain profile ID(s) and other params per layer */
 	struct LIST_HEAD_TYPE rl_prof_list[ICE_AQC_TOPO_MAX_LEVEL_NUM];
-#if !defined(NO_DCB_SUPPORT) || defined(ADQ_SUPPORT)
 	struct ice_dcbx_cfg local_dcbx_cfg;	/* Oper/Local Cfg */
-#endif /* !NO_DCB_SUPPORT || ADQ_SUPPORT */
+	/* DCBX info */
+	struct ice_dcbx_cfg remote_dcbx_cfg;	/* Peer Cfg */
+	struct ice_dcbx_cfg desired_dcbx_cfg;	/* CEE Desired Cfg */
+	/* LLDP/DCBX Status */
+	u8 dcbx_status;
+	u8 is_sw_lldp;
 	u8 lport;
 #define ICE_LPORT_MASK		0xff
 	u8 is_vf;
drivers/net/ice/base/meson.build +1 -0
index d7f8536bc..755d2497b 100644
@@ -9,6 +9,7 @@ sources = [
 	'ice_nvm.c',
 	'ice_flex_pipe.c',
 	'ice_flow.c',
+	'ice_dcb.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
Signature · 1 line
2.13.6
author
#77 lore raw

PATCH v2 32/37 net/ice/base: add FDIR support

In reply to Qi Zhang

Add flow director related support base code.

---
 drivers/net/ice/Makefile              |   1 +
 drivers/net/ice/base/ice_adminq_cmd.h |  13 +
 drivers/net/ice/base/ice_common.c     |  36 ++
 drivers/net/ice/base/ice_common.h     |   1 +
 drivers/net/ice/base/ice_fdir.c       | 742 ++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_fdir.h       | 202 +++++++++
 drivers/net/ice/base/ice_flex_pipe.c  | 232 +++++++++++
 drivers/net/ice/base/ice_type.h       |  55 +++
 drivers/net/ice/base/meson.build      |   1 +
 9 files changed, 1283 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_fdir.c
 create mode 100644 drivers/net/ice/base/ice_fdir.h
drivers/net/ice/Makefile +1 -0
index 89d21334e..a3aabccf1 100644
@@ -52,6 +52,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_nvm.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flex_pipe.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_flow.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcb.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_fdir.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_rxtx.c
drivers/net/ice/base/ice_adminq_cmd.h +13 -0
index 4c5cf5419..d2ab9eeff 100644
@@ -105,6 +105,7 @@ struct ice_aqc_list_caps_elem {
 #define ICE_AQC_CAPS_RXQS				0x0041
 #define ICE_AQC_CAPS_TXQS				0x0042
 #define ICE_AQC_CAPS_MSIX				0x0043
+#define ICE_AQC_CAPS_FD					0x0045
 #define ICE_AQC_CAPS_MAX_MTU				0x0047
 
 	u8 major_ver;
@@ -1861,6 +1862,16 @@ struct ice_aqc_get_set_rss_lut {
 };
 
 
+/* Clear FD Table Command (direct, 0x0B06) */
+struct ice_aqc_clear_fd_table {
+	u8 clear_type;
+#define CL_FD_VM_VF_TYPE_VSI_IDX	1
+#define CL_FD_VM_VF_TYPE_PF_IDX		2
+	u8 rsvd;
+	__le16 vsi_index;
+	u8 reserved[12];
+};
+
 
 
 
@@ -2210,6 +2221,7 @@ struct ice_aq_desc {
 		struct ice_aqc_lldp_stop_start_specific_agent lldp_agent_ctrl;
 		struct ice_aqc_get_set_rss_lut get_set_rss_lut;
 		struct ice_aqc_get_set_rss_key get_set_rss_key;
+		struct ice_aqc_clear_fd_table clear_fd_table;
 		struct ice_aqc_add_txqs add_txqs;
 		struct ice_aqc_dis_txqs dis_txqs;
 		struct ice_aqc_txqs_cleanup txqs_cleanup;
@@ -2415,6 +2427,7 @@ enum ice_adminq_opc {
 	ice_aqc_opc_set_rss_lut				= 0x0B03,
 	ice_aqc_opc_get_rss_key				= 0x0B04,
 	ice_aqc_opc_get_rss_lut				= 0x0B05,
+	ice_aqc_opc_clear_fd_table			= 0x0B06,
 
 	/* Tx queue handling commands/events */
 	ice_aqc_opc_add_txqs				= 0x0C30,
drivers/net/ice/base/ice_common.c +36 -0
index 202592710..425f76e8d 100644
@@ -805,6 +805,9 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 	if (status)
 		goto err_unroll_cqinit;
 
+	/* Set bit to enable Flow Director filters */
+	wr32(hw, PFQF_FD_ENA, PFQF_FD_ENA_FD_ENA_M);
+	INIT_LIST_HEAD(&hw->fdir_list_head);
 
 	ice_clear_pxe_mode(hw);
 
@@ -901,6 +904,10 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 	ice_init_flex_flds(hw, ICE_RXDID_FLEX_NIC);
 	ice_init_flex_flds(hw, ICE_RXDID_FLEX_NIC_2);
 
+	/* Obtain counter base index which would be used by flow director */
+	status = ice_alloc_fd_res_cntr(hw, &hw->fd_ctr_base);
+	if (status)
+		goto err_unroll_fltr_mgmt_struct;
 
 	return ICE_SUCCESS;
 
@@ -926,6 +933,7 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
  */
 void ice_deinit_hw(struct ice_hw *hw)
 {
+	ice_free_fd_res_cntr(hw, hw->fd_ctr_base);
 	ice_cleanup_fltr_mgmt_struct(hw);
 
 	ice_sched_cleanup_all(hw);
@@ -1980,6 +1988,34 @@ ice_parse_caps(struct ice_hw *hw, void *buf, u32 cap_count,
 				  "HW caps: MSIX first vector index = %d\n",
 				  caps->msix_vector_first_id);
 			break;
+		case ICE_AQC_CAPS_FD:
+		{
+			u32 reg_val, val;
+
+			if (dev_p) {
+				dev_p->num_flow_director_fltr = number;
+				ice_debug(hw, ICE_DBG_INIT,
+					  "HW caps: Dev.fd_fltr =%d\n",
+					  dev_p->num_flow_director_fltr);
+			}
+			if (func_p) {
+				reg_val = rd32(hw, GLQF_FD_SIZE);
+				val = (reg_val & GLQF_FD_SIZE_FD_GSIZE_M) >>
+				      GLQF_FD_SIZE_FD_GSIZE_S;
+				func_p->fd_fltr_guar =
+					ice_get_num_per_func(hw, val);
+				val = (reg_val & GLQF_FD_SIZE_FD_BSIZE_M) >>
+				      GLQF_FD_SIZE_FD_BSIZE_S;
+				func_p->fd_fltr_best_effort = val;
+				ice_debug(hw, ICE_DBG_INIT,
+					  "HW:func.fd_fltr guar= %d\n",
+					  func_p->fd_fltr_guar);
+				ice_debug(hw, ICE_DBG_INIT,
+					  "HW:func.fd_fltr best effort=%d\n",
+					  func_p->fd_fltr_best_effort);
+			}
+			break;
+		}
 		case ICE_AQC_CAPS_MAX_MTU:
 			caps->max_mtu = number;
 			if (dev_p)
drivers/net/ice/base/ice_common.h +1 -0
index 9665f3204..4dc43dcfe 100644
@@ -9,6 +9,7 @@
 
 #include "ice_flex_pipe.h"
 #include "ice_switch.h"
+#include "ice_fdir.h"
 
 enum ice_fw_modes {
 	ICE_FW_MODE_NORMAL,
drivers/net/ice/base/ice_fdir.c new file +742 -0

742 lines not on this page · raw message

drivers/net/ice/base/ice_fdir.h new file +202 -0

202 lines not on this page · raw message

drivers/net/ice/base/ice_flex_pipe.c +232 -0

256 lines not on this page · raw message

drivers/net/ice/base/ice_type.h +55 -0

103 lines not on this page · raw message

drivers/net/ice/base/meson.build +1 -0
index 755d2497b..624202567 100644
@@ -10,6 +10,7 @@ sources = [
 	'ice_flex_pipe.c',
 	'ice_flow.c',
 	'ice_dcb.c',
+	'ice_fdir.c',
 ]
 
 error_cflags = ['-Wno-unused-value',
Signature · 1 line
2.13.6
author
#78 lore raw

PATCH v2 33/37 net/ice/base: change profile priority for RSS reply

In reply to Qi Zhang

1. Add call to replay RSS configurations
2. Add RSS configurations to end of list and not the head to avoid inversion on replay.

---
 drivers/net/ice/base/ice_common.c |  5 ++++-
 drivers/net/ice/base/ice_flow.c   |  3 ++-
 drivers/net/ice/base/ice_osdep.h  | 16 ++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/ice/base/ice_common.c +4 -1
index 425f76e8d..74f925c03 100644
@@ -3854,7 +3854,10 @@ enum ice_status ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle)
 		if (status)
 			return status;
 	}
-
+	/* Replay per VSI all RSS configurations */
+	status = ice_replay_rss_cfg(hw, vsi_handle);
+	if (status)
+		return status;
 	/* Replay per VSI all filters */
 	status = ice_replay_vsi_all_fltr(hw, vsi_handle);
 	if (!status)
drivers/net/ice/base/ice_flow.c +2 -1
index 03a324d49..428002c28 100644
@@ -1672,7 +1672,8 @@ ice_add_rss_vsi_ctx(struct ice_hw *hw, u16 vsi_handle,
 
 	rss_cfg->hashed_flds = prof->segs[prof->segs_cnt - 1].match;
 	rss_cfg->packet_hdr = prof->segs[prof->segs_cnt - 1].hdrs;
-	LIST_ADD(&rss_cfg->l_entry, &hw->vsi_ctx[vsi_handle]->rss_list_head);
+	LIST_ADD_TAIL(&rss_cfg->l_entry,
+		      &hw->vsi_ctx[vsi_handle]->rss_list_head);
 
 	return ICE_SUCCESS;
 }
drivers/net/ice/base/ice_osdep.h +16 -0
index 252c8f4e7..560e36c1b 100644
@@ -462,6 +462,22 @@ LIST_HEAD(ice_list_head, ice_list_entry);
 #define LIST_ADD(entry, list_head)    LIST_INSERT_HEAD(list_head, entry, next)
 #define LIST_ADD_AFTER(entry, list_entry) \
 	LIST_INSERT_AFTER(list_entry, entry, next)
+
+static inline void list_add_tail(struct ice_list_entry *entry,
+				 struct ice_list_head *head)
+{
+	struct ice_list_entry *tail = head->lh_first;
+
+	if (tail == NULL) {
+		LIST_INSERT_HEAD(head, entry, next);
+		return;
+	}
+	while (tail->next.le_next != NULL)
+		tail = tail->next.le_next;
+	LIST_INSERT_AFTER(tail, entry, next);
+}
+
+#define LIST_ADD_TAIL(entry, head) list_add_tail(entry, head)
 #define LIST_FOR_EACH_ENTRY(pos, head, type, member)			       \
 	for ((pos) = (head)->lh_first ?					       \
 		     container_of((head)->lh_first, struct type, member) :     \
Signature · 1 line
2.13.6
author
#79 lore raw

PATCH v2 34/37 net/ice/base: fix duplicate resource allocations

In reply to Qi Zhang

This patch ensure that TCAM allocations made by a newly added VSIG that has the same characteristic list of an existing VSIG are removed.

Fixes 51d04e4933e3 ("net/ice/base: add flexible pipeline module")
---
 drivers/net/ice/base/ice_flex_pipe.c | 85 +++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 44 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +41 -44
index 37bb4cbb5..c9d8730d2 100644
@@ -2302,21 +2302,23 @@ ice_vsig_free(struct ice_hw *hw, enum ice_block blk, u16 vsig)
 	hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false;
 
 	vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
-	if (!vsi_cur)
-		return ICE_ERR_CFG;
-
-	/* remove all vsis associated with this VSIG XLT2 entry */
-	do {
-		struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
-
-		vsi_cur->vsig = ICE_DEFAULT_VSIG;
-		vsi_cur->changed = 1;
-		vsi_cur->next_vsi = NULL;
-		vsi_cur = tmp;
-	} while (vsi_cur);
-
-	/* NULL terminate head of vsi list */
-	hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL;
+	/* If the VSIG has at least 1 VSI then iterate through the
+	 * list and remove the VSIs before deleting the group.
+	 */
+	if (vsi_cur) {
+		/* remove all vsis associated with this VSIG XLT2 entry */
+		do {
+			struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
+
+			vsi_cur->vsig = ICE_DEFAULT_VSIG;
+			vsi_cur->changed = 1;
+			vsi_cur->next_vsi = NULL;
+			vsi_cur = tmp;
+		} while (vsi_cur);
+
+		/* NULL terminate head of VSI list */
+		hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL;
+	}
 
 	/* free characteristic list */
 	LIST_FOR_EACH_ENTRY_SAFE(del, dtmp,
@@ -4267,36 +4269,32 @@ ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
 
 	/* Move all VSIS associated with this VSIG to the default VSIG */
 	vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
-	if (!vsi_cur)
-		return ICE_ERR_CFG;
-
-	do {
-		struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
-		struct ice_chs_chg *p;
-
-		p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
-		if (!p)
-			goto err_ice_rem_vsig;
+	/* If the VSIG has at least 1 VSI then iterate through the list
+	 * and remove the VSIs before deleting the group.
+	 */
+	if (vsi_cur) {
+		do {
+			struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
+			struct ice_chs_chg *p;
 
-		p->type = ICE_VSIG_REM;
-		p->orig_vsig = vsig;
-		p->vsig = ICE_DEFAULT_VSIG;
-		p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis;
+			p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p));
+			if (!p)
+				return ICE_ERR_NO_MEMORY;
 
-		LIST_ADD(&p->list_entry, chg);
+			p->type = ICE_VSIG_REM;
+			p->orig_vsig = vsig;
+			p->vsig = ICE_DEFAULT_VSIG;
+			p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis;
 
-		status = ice_vsig_free(hw, blk, vsig);
-		if (status)
-			return status;
+			LIST_ADD(&p->list_entry, chg);
 
-		vsi_cur = tmp;
-	} while (vsi_cur);
+			vsi_cur = tmp;
+		} while (vsi_cur);
+	}
 
-	return ICE_SUCCESS;
+	status = ice_vsig_free(hw, blk, vsig);
 
-err_ice_rem_vsig:
-	/* the caller will free up the change list */
-	return ICE_ERR_NO_MEMORY;
+	return status;
 }
 
 /**
@@ -4493,7 +4491,7 @@ ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig,
 
 		ice_memcpy(p, ent1, sizeof(*p), ICE_NONDMA_TO_NONDMA);
 
-		LIST_ADD(&p->list, lst);
+		LIST_ADD_TAIL(&p->list, lst);
 	}
 
 	return ICE_SUCCESS;
@@ -5000,14 +4998,13 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl)
 		/* search for an existing VSIG with an exact charc match */
 		status = ice_find_dup_props_vsig(hw, blk, &union_lst, &vsig);
 		if (!status) {
-			/* found an exact match */
-			/* move vsi to the VSIG that matches */
+			/* move VSI to the VSIG that matches */
 			status = ice_move_vsi(hw, blk, vsi, vsig, &chg);
 			if (status)
 				goto err_ice_add_prof_id_flow;
 
-			/* remove original VSIG if we just moved the only VSI
-			 * from it
+			/* VSI has been moved out of or_vsig. If the or_vsig had
+			 * only that VSI it is now empty and can be removed.
 			 */
 			if (only_vsi) {
 				status = ice_rem_vsig(hw, blk, or_vsig, &chg);
Signature · 1 line
2.13.6
author
#80 lore raw

PATCH v2 35/37 net/ice/base: minor fix

In reply to Qi Zhang

1. clean flow entry's action structure after remove it.
2. initialized priority when add a new flow entry
3. remove RSS configuration before deleting the flow profile.

Fixes aa1cd410fa64 ("net/ice/base: add flow module")
Fixes 51d04e4933e3 ("net/ice/base: add flexible pipeline module")
---
 drivers/net/ice/base/ice_flex_pipe.c |  2 +-
 drivers/net/ice/base/ice_flow.c      | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/ice/base/ice_flex_pipe.c +1 -1
index c9d8730d2..e4d0b8c0f 100644
@@ -2467,7 +2467,7 @@ ice_find_prof_id(struct ice_hw *hw, enum ice_block blk,
 	for (i = 0; i < es->count; i++) {
 		off = i * es->fvw;
 
-		if (memcmp(&es->t[off], fv, es->fvw * 2))
+		if (memcmp(&es->t[off], fv, es->fvw * sizeof(*fv)))
 			continue;
 
 		*prof_id = i;
drivers/net/ice/base/ice_flow.c +10 -3
index 428002c28..98727cfeb 100644
@@ -910,8 +910,11 @@ ice_flow_rem_entry_sync(struct ice_hw *hw, struct ice_flow_entry *entry)
 	if (entry->entry)
 		ice_free(hw, entry->entry);
 
-	if (entry->acts)
+	if (entry->acts) {
 		ice_free(hw, entry->acts);
+		entry->acts = NULL;
+		entry->acts_cnt = 0;
+	}
 
 	ice_free(hw, entry);
 
@@ -1306,6 +1309,7 @@ ice_flow_add_entry(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
 	e->id = entry_id;
 	e->vsi_handle = vsi_handle;
 	e->prof = prof;
+	e->priority = prio;
 
 	switch (blk) {
 	case ICE_BLK_RSS:
@@ -1852,11 +1856,14 @@ ice_rem_rss_cfg_sync(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
 	if (status)
 		goto out;
 
+	/* Remove RSS configuration from VSI context before deleting
+	 * the flow profile.
+	 */
+	ice_rem_rss_cfg_vsi_ctx(hw, vsi_handle, prof);
+
 	if (!ice_is_any_bit_set(prof->vsis, ICE_MAX_VSI))
 		status = ice_flow_rem_prof_sync(hw, blk, prof);
 
-	ice_rem_rss_cfg_vsi_ctx(hw, vsi_handle, prof);
-
 out:
 	ice_free(hw, segs);
 	return status;
Signature · 1 line
2.13.6
author
#81 lore raw

PATCH v2 36/37 net/ice/base: increase prototol offset size

In reply to Qi Zhang

OS package's format is changed, field vector's protocol offset size is changed from 8 bit to 16 bit. So base code also need to align to this, or PMD will not be able to load OS package correctly.

---
 drivers/net/ice/base/ice_flex_type.h     | 8 +++++++-
 drivers/net/ice/base/ice_flow.c          | 7 +++++--
 drivers/net/ice/base/ice_flow.h          | 2 +-
 drivers/net/ice/base/ice_protocol_type.h | 2 +-
 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/ice/base/ice_flex_type.h +7 -1
index 365f33390..f259e1371 100644
@@ -5,12 +5,18 @@
 #ifndef _ICE_FLEX_TYPE_H_
 #define _ICE_FLEX_TYPE_H_
 
+#define ICE_FV_OFFSET_INVAL    0x1FF
+
+#pragma pack(1)
 /* Extraction Sequence (Field Vector) Table */
 struct ice_fv_word {
 	u8 prot_id;
-	u8 off;		/* Offset within the protocol header */
+	u16 off;		/* Offset within the protocol header */
+	u8 resvrd;
 };
 
+#pragma pack()
+
 #define ICE_MAX_FV_WORDS 48
 struct ice_fv {
 	struct ice_fv_word ew[ICE_MAX_FV_WORDS];
drivers/net/ice/base/ice_flow.c +5 -2
index 98727cfeb..be819e0e9 100644
@@ -516,7 +516,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
 	struct ice_flow_fld_info *flds;
 	u16 cnt, ese_bits, i;
 	s16 adj = 0;
-	u8 off;
+	u16 off;
 
 	flds = params->prof->segs[seg].fields;
 
@@ -956,7 +956,10 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk,
 		return ICE_ERR_NO_MEMORY;
 
 	/* initialize extraction sequence to all invalid (0xff) */
-	ice_memset(params.es, 0xff, sizeof(params.es), ICE_NONDMA_MEM);
+	for (i = 0; i < ICE_MAX_FV_WORDS; i++) {
+		params.es[i].prot_id = ICE_PROT_INVALID;
+		params.es[i].off = ICE_FV_OFFSET_INVAL;
+	}
 
 	params.blk = blk;
 	params.prof->id = prof_id;
drivers/net/ice/base/ice_flow.h +1 -1
index bad925c8c..f0c74a348 100644
@@ -174,7 +174,7 @@ enum ice_flow_priority {
 
 struct ice_flow_seg_xtrct {
 	u8 prot_id;	/* Protocol ID of extracted header field */
-	u8 off;		/* Starting offset of the field in header in bytes */
+	u16 off;	/* Starting offset of the field in header in bytes */
 	u8 idx;		/* Index of FV entry used */
 	u8 disp;	/* Displacement of field in bits fr. FV entry's start */
 };
drivers/net/ice/base/ice_protocol_type.h +1 -1
index 6b3bd6542..e572dd320 100644
@@ -223,7 +223,7 @@ struct ice_prot_lkup_ext {
 	u16 prot_type;
 	u8 n_val_words;
 	/* create a buffer to hold max words per recipe */
-	u8 field_off[ICE_MAX_CHAIN_WORDS];
+	u16 field_off[ICE_MAX_CHAIN_WORDS];
 
 	struct ice_fv_word fv_words[ICE_MAX_CHAIN_WORDS];
 
Signature · 1 line
2.13.6
author
#82 lore raw

PATCH v2 37/37 net/ice/base: revert the workaround for resource allocation

In reply to Qi Zhang

Revert the workaround for allocating TCAM and FV entries to align with latest firmware.

---
 drivers/net/ice/base/ice_common.c    |  11 +-
 drivers/net/ice/base/ice_common.h    |   2 +-
 drivers/net/ice/base/ice_flex_pipe.c | 235 ++---------------------------------
 drivers/net/ice/base/ice_flex_type.h |   2 -
 4 files changed, 17 insertions(+), 233 deletions(-)
drivers/net/ice/base/ice_common.c +7 -4
index 74f925c03..3d2e5f347 100644
@@ -1786,11 +1786,11 @@ ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
  * @hw: pointer to the HW struct
  * @type: type of resource
  * @num: number of resources to allocate
- * @sh: shared if true, dedicated if false
+ * @btm: allocate from bottom
  * @res: pointer to array that will receive the resources
  */
 enum ice_status
-ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool sh, u16 *res)
+ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res)
 {
 	struct ice_aqc_alloc_free_res_elem *buf;
 	enum ice_status status;
@@ -1804,8 +1804,11 @@ ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool sh, u16 *res)
 
 	/* Prepare buffer to allocate resource. */
 	buf->num_elems = CPU_TO_LE16(num);
-	buf->res_type = CPU_TO_LE16(type | (sh ? ICE_AQC_RES_TYPE_FLAG_SHARED :
-		ICE_AQC_RES_TYPE_FLAG_DEDICATED));
+	buf->res_type = CPU_TO_LE16(type | ICE_AQC_RES_TYPE_FLAG_DEDICATED |
+				    ICE_AQC_RES_TYPE_FLAG_IGNORE_INDEX);
+	if (btm)
+		buf->res_type |= CPU_TO_LE16(ICE_AQC_RES_TYPE_FLAG_SCAN_BOTTOM);
+
 	status = ice_aq_alloc_free_res(hw, 1, buf, buf_len,
 				       ice_aqc_opc_alloc_res, NULL);
 	if (status)
drivers/net/ice/base/ice_common.h +1 -1
index 4dc43dcfe..e8f2ce9d8 100644
@@ -41,7 +41,7 @@ ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res,
 		enum ice_aq_res_access_type access, u32 timeout);
 void ice_release_res(struct ice_hw *hw, enum ice_aq_res_ids res);
 enum ice_status
-ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool sh, u16 *res);
+ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res);
 enum ice_status
 ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res);
 enum ice_status
drivers/net/ice/base/ice_flex_pipe.c +9 -226

292 lines not on this page · raw message

drivers/net/ice/base/ice_flex_type.h +0 -2
index f259e1371..f2a5f27e7 100644
@@ -507,7 +507,6 @@ struct ice_es {
 	u8 reverse; /* set to true to reverse FV order */
 	struct LIST_HEAD_TYPE prof_map;
 	struct ice_fv_word *t;
-	u8 *resource_used_hack; /* hack for testing */
 };
 
 /* PTYPE Group management */
@@ -660,7 +659,6 @@ struct ice_prof_tcam {
 	u16 max_prof_id;
 	u8 cdid_bits; /* # cdid bits to use in key, 0, 2, 4, or 8 */
 	struct ice_prof_tcam_entry *t;
-	u8 *resource_used_hack;
 };
 
 struct ice_prof_redir {
Signature · 1 line
2.13.6
author
#83 lore raw

v3 cover ice share code update.

In reply to Qi Zhang

Sync to latest kernel driver, main changes:
1. add DCB/FDIR support.
2. add more APIs in switch module.
3. code clean and bug fix.

v3:
- fix software queue handle parsing in ice_ena_vsi_txq and ice_dis_vsi_txq (PATCH 19/38) which will cause Tx queue setup fail during device reconfigure.
- Add new fix for UDP PTYPE setup. (PATCH 38/38), which will cause IPv4 TCP RSS does not work at some situation.

v2:
- Enhanced the commit log
- Add missing fixed line.

Qi Zhang (38):
net/ice/base: add switch resource allocation and free net/ice/base: improve comments
net/ice/base: add two helper functions net/ice/base: add helper macros
net/ice/base: allow package copy to be used after resets net/ice/base: code clean
net/ice/base: declare functions as external net/ice/base: add more APIs in switch module net/ice/base: add VSI queue context framework net/ice/base: add APIs to add remove ethertype filter net/ice/base: add APIs to get allocated resources net/ice/base: add APIs to alloc/free resource counter net/ice/base: add APIs to get VSI promiscuous mode net/ice/base: add MAC filter with marker and counter net/ice/base: add two helper functions for flow management net/ice/base: minor fix
net/ice/base: update macros
net/ice/base: code clean
net/ice/base: enable VSI queue context net/ice/base: ensure only valid bits are set net/ice/base: enhance get link status command net/ice/base: add RSS key related macro and structures net/ice/base: do not write TCAM entries back net/ice/base: remove local VSIG allocations net/ice/base: minor fix
net/ice/base: update copyright time
net/ice/base: fix static analysis reported issues net/ice/base: return config error without queue to disable net/ice/base: add function to check FW recovery mode net/ice/base: change profile id reference counting net/ice/base: add DCB support
net/ice/base: add FDIR support
net/ice/base: change profile priority for RSS reply net/ice/base: fix duplicate resource allocations net/ice/base: minor fix
net/ice/base: increase prototol offset size net/ice/base: revert the workaround for resource allocation net/ice/base: fix set UDP PTYPEs

 drivers/net/ice/Makefile                 |    2 +
 drivers/net/ice/base/ice_adminq_cmd.h    |  515 +++++-
 drivers/net/ice/base/ice_alloc.h         |    2 +-
 drivers/net/ice/base/ice_common.c        |  650 ++++++--
 drivers/net/ice/base/ice_common.h        |   36 +-
 drivers/net/ice/base/ice_controlq.c      |   10 +-
 drivers/net/ice/base/ice_controlq.h      |    2 +-
 drivers/net/ice/base/ice_dcb.c           | 1393 ++++++++++++++++
 drivers/net/ice/base/ice_dcb.h           |  223 +++
 drivers/net/ice/base/ice_devids.h        |    2 +-
 drivers/net/ice/base/ice_fdir.c          |  742 +++++++++
 drivers/net/ice/base/ice_fdir.h          |  202 +++
 drivers/net/ice/base/ice_flex_pipe.c     | 1075 +++++++------
 drivers/net/ice/base/ice_flex_pipe.h     |    4 +-
 drivers/net/ice/base/ice_flex_type.h     |   19 +-
 drivers/net/ice/base/ice_flow.c          |  228 +--
 drivers/net/ice/base/ice_flow.h          |   22 +-
 drivers/net/ice/base/ice_hw_autogen.h    |    2 +-
 drivers/net/ice/base/ice_lan_tx_rx.h     |  149 +-
 drivers/net/ice/base/ice_nvm.c           |   17 +-
 drivers/net/ice/base/ice_osdep.h         |   16 +
 drivers/net/ice/base/ice_protocol_type.h |    8 +-
 drivers/net/ice/base/ice_sbq_cmd.h       |    2 +-
 drivers/net/ice/base/ice_sched.c         | 2563 +++++++++++++++---------------
 drivers/net/ice/base/ice_sched.h         |   34 +-
 drivers/net/ice/base/ice_status.h        |    3 +-
 drivers/net/ice/base/ice_switch.c        | 1315 ++++++++++++++-
 drivers/net/ice/base/ice_switch.h        |  109 +-
 drivers/net/ice/base/ice_type.h          |  119 +-
 drivers/net/ice/base/meson.build         |    2 +
 drivers/net/ice/ice_rxtx.c               |   13 +-
 31 files changed, 7114 insertions(+), 2365 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_dcb.c
 create mode 100644 drivers/net/ice/base/ice_dcb.h
 create mode 100644 drivers/net/ice/base/ice_fdir.c
 create mode 100644 drivers/net/ice/base/ice_fdir.h
Signature · 1 line
2.13.6
author
#84 lore raw

PATCH v3 1/38 net/ice/base: add switch resource allocation and free

Add two APIs ice_alloc_sw and ice_free_sw to support switch related resource allocation and free.

These APIs is required when we enable switch flow.

---
 drivers/net/ice/base/ice_switch.c | 150 ++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_switch.h |   5 ++
 2 files changed, 155 insertions(+)
drivers/net/ice/base/ice_switch.c +150 -0
index 0379cd045..a7b712e17 100644
@@ -129,6 +129,156 @@ ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp *buf,
 }
 
 
+/**
+ * ice_alloc_sw - allocate resources specific to switch
+ * @hw: pointer to the HW struct
+ * @ena_stats: true to turn on VEB stats
+ * @shared_res: true for shared resource, false for dedicated resource
+ * @sw_id: switch ID returned
+ * @counter_id: VEB counter ID returned
+ *
+ * allocates switch resources (SWID and VEB counter) (0x0208)
+ */
+enum ice_status
+ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
+	     u16 *counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf;
+	struct ice_aqc_res_elem *sw_ele;
+	enum ice_status status;
+	u16 buf_len;
+
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		   ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	/* Prepare buffer for switch ID.
+	 * The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is allocated, and hence a single sw_id
+	 * is requested.
+	 */
+	sw_buf->num_elems = CPU_TO_LE16(1);
+	sw_buf->res_type =
+		CPU_TO_LE16(ICE_AQC_RES_TYPE_SWID |
+			    (shared_res ? ICE_AQC_RES_TYPE_FLAG_SHARED :
+			    ICE_AQC_RES_TYPE_FLAG_DEDICATED));
+
+	status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+				       ice_aqc_opc_alloc_res, NULL);
+
+	if (status)
+		goto ice_alloc_sw_exit;
+
+	sw_ele = &sw_buf->elem[0];
+	*sw_id = LE16_TO_CPU(sw_ele->e.sw_resp);
+
+	if (ena_stats) {
+		/* Prepare buffer for VEB Counter */
+		enum ice_adminq_opc opc = ice_aqc_opc_alloc_res;
+		struct ice_aqc_alloc_free_res_elem *counter_buf;
+		struct ice_aqc_res_elem *counter_ele;
+
+		counter_buf = (struct ice_aqc_alloc_free_res_elem *)
+				ice_malloc(hw, buf_len);
+		if (!counter_buf) {
+			status = ICE_ERR_NO_MEMORY;
+			goto ice_alloc_sw_exit;
+		}
+
+		/* The number of resource entries in buffer is passed as 1 since
+		 * only a single switch/VEB instance is allocated, and hence a
+		 * single VEB counter is requested.
+		 */
+		counter_buf->num_elems = CPU_TO_LE16(1);
+		counter_buf->res_type =
+			CPU_TO_LE16(ICE_AQC_RES_TYPE_VEB_COUNTER |
+				    ICE_AQC_RES_TYPE_FLAG_DEDICATED);
+		status = ice_aq_alloc_free_res(hw, 1, counter_buf, buf_len,
+					       opc, NULL);
+
+		if (status) {
+			ice_free(hw, counter_buf);
+			goto ice_alloc_sw_exit;
+		}
+		counter_ele = &counter_buf->elem[0];
+		*counter_id = LE16_TO_CPU(counter_ele->e.sw_resp);
+		ice_free(hw, counter_buf);
+	}
+
+ice_alloc_sw_exit:
+	ice_free(hw, sw_buf);
+	return status;
+}
+
+/**
+ * ice_free_sw - free resources specific to switch
+ * @hw: pointer to the HW struct
+ * @sw_id: switch ID returned
+ * @counter_id: VEB counter ID returned
+ *
+ * free switch resources (SWID and VEB counter) (0x0209)
+ *
+ * NOTE: This function frees multiple resources. It continues
+ * releasing other resources even after it encounters error.
+ * The error code returned is the last error it encountered.
+ */
+enum ice_status ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id)
+{
+	struct ice_aqc_alloc_free_res_elem *sw_buf, *counter_buf;
+	enum ice_status status, ret_status;
+	u16 buf_len;
+
+	buf_len = sizeof(*sw_buf);
+	sw_buf = (struct ice_aqc_alloc_free_res_elem *)
+		   ice_malloc(hw, buf_len);
+	if (!sw_buf)
+		return ICE_ERR_NO_MEMORY;
+
+	/* Prepare buffer to free for switch ID res.
+	 * The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is freed, and hence a single sw_id
+	 * is released.
+	 */
+	sw_buf->num_elems = CPU_TO_LE16(1);
+	sw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_SWID);
+	sw_buf->elem[0].e.sw_resp = CPU_TO_LE16(sw_id);
+
+	ret_status = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,
+					   ice_aqc_opc_free_res, NULL);
+
+	if (ret_status)
+		ice_debug(hw, ICE_DBG_SW, "CQ CMD Buffer:\n");
+
+	/* Prepare buffer to free for VEB Counter resource */
+	counter_buf = (struct ice_aqc_alloc_free_res_elem *)
+			ice_malloc(hw, buf_len);
+	if (!counter_buf) {
+		ice_free(hw, sw_buf);
+		return ICE_ERR_NO_MEMORY;
+	}
+
+	/* The number of resource entries in buffer is passed as 1 since only a
+	 * single switch/VEB instance is freed, and hence a single VEB counter
+	 * is released
+	 */
+	counter_buf->num_elems = CPU_TO_LE16(1);
+	counter_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_VEB_COUNTER);
+	counter_buf->elem[0].e.sw_resp = CPU_TO_LE16(counter_id);
+
+	status = ice_aq_alloc_free_res(hw, 1, counter_buf, buf_len,
+				       ice_aqc_opc_free_res, NULL);
+	if (status) {
+		ice_debug(hw, ICE_DBG_SW,
+			  "VEB counter resource could not be freed\n");
+		ret_status = status;
+	}
+
+	ice_free(hw, counter_buf);
+	ice_free(hw, sw_buf);
+	return ret_status;
+}
 
 /**
  * ice_aq_add_vsi
drivers/net/ice/base/ice_switch.h +5 -0
index 66a172fc2..dd21781f7 100644
@@ -290,6 +290,11 @@ ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id);
 /* Switch/bridge related commands */
 enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
 enum ice_status
+ice_alloc_sw(struct ice_hw *hw, bool ena_stats, bool shared_res, u16 *sw_id,
+	     u16 *counter_id);
+enum ice_status
+ice_free_sw(struct ice_hw *hw, u16 sw_id, u16 counter_id);
+enum ice_status
 ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
Signature · 1 line
2.13.6