diff mbox series

[net-next,5/6] sfc: introduce pedit add actions on the ipv4 ttl field

Message ID 20230823111725.28090-6-pieter.jansen-van-vuuren@amd.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series sfc: introduce eth, ipv4 and ipv6 pedit offloads | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1331 this patch: 1331
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 1354 this patch: 1354
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1354 this patch: 1354
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: line length of 92 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0

Commit Message

Pieter Jansen van Vuuren Aug. 23, 2023, 11:17 a.m. UTC
Introduce pedit add actions and use it to achieve decrement ttl offload.
Decrement ttl can be achieved by adding 0xff to the ttl field.

Co-developed-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
---
 drivers/net/ethernet/sfc/tc.c | 45 +++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

kernel test robot Aug. 23, 2023, 2:25 p.m. UTC | #1
Hi Pieter,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Pieter-Jansen-van-Vuuren/sfc-introduce-ethernet-pedit-set-action-infrastructure/20230823-192051
base:   net-next/main
patch link:    https://lore.kernel.org/r/20230823111725.28090-6-pieter.jansen-van-vuuren%40amd.com
patch subject: [PATCH net-next 5/6] sfc: introduce pedit add actions on the ipv4 ttl field
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230823/202308232244.jYYwKnlV-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230823/202308232244.jYYwKnlV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308232244.jYYwKnlV-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/sfc/tc.c:1073: warning: expecting prototype for efx_tc_mangle(). Prototype was for efx_tc_pedit_add() instead


vim +1073 drivers/net/ethernet/sfc/tc.c

  1056	
  1057	/**
  1058	 * efx_tc_mangle() - handle a single 32-bit (or less) pedit
  1059	 * @efx: NIC we're installing a flow rule on
  1060	 * @act: action set (cursor) to update
  1061	 * @fa:          FLOW_ACTION_MANGLE action metadata
  1062	 * @mung:        accumulator for partial mangles
  1063	 * @extack:      netlink extended ack for reporting errors
  1064	 *
  1065	 * Identify the fields written by a FLOW_ACTION_MANGLE, and record
  1066	 * the partial mangle state in @mung.  If this mangle completes an
  1067	 * earlier partial mangle, consume and apply to @act by calling
  1068	 * efx_tc_complete_mac_mangle().
  1069	 */
  1070	static int efx_tc_pedit_add(struct efx_nic *efx, struct efx_tc_action_set *act,
  1071				    const struct flow_action_entry *fa,
  1072				    struct netlink_ext_ack *extack)
> 1073	{
  1074		switch (fa->mangle.htype) {
  1075		case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
  1076			switch (fa->mangle.offset) {
  1077			case offsetof(struct iphdr, ttl):
  1078				/* check that pedit applies to ttl only */
  1079				if (fa->mangle.mask != ~EFX_TC_HDR_TYPE_TTL_MASK)
  1080					break;
  1081	
  1082				/* Adding 0xff is equivalent to decrementing the ttl.
  1083				 * Other added values are not supported.
  1084				 */
  1085				if ((fa->mangle.val & EFX_TC_HDR_TYPE_TTL_MASK) != U8_MAX)
  1086					break;
  1087	
  1088				/* check that we do not decrement ttl twice */
  1089				if (!efx_tc_flower_action_order_ok(act,
  1090								   EFX_TC_AO_DEC_TTL)) {
  1091					NL_SET_ERR_MSG_MOD(extack, "Unsupported: multiple dec ttl");
  1092					return -EOPNOTSUPP;
  1093				}
  1094				act->do_ttl_dec = 1;
  1095				return 0;
  1096			default:
  1097				break;
  1098			}
  1099			break;
  1100		default:
  1101			break;
  1102		}
  1103	
  1104		NL_SET_ERR_MSG_FMT_MOD(extack,
  1105				       "Unsupported: ttl add action type %x %x %x/%x",
  1106				       fa->mangle.htype, fa->mangle.offset,
  1107				       fa->mangle.val, fa->mangle.mask);
  1108		return -EOPNOTSUPP;
  1109	}
  1110
Pieter Jansen van Vuuren Aug. 23, 2023, 3:01 p.m. UTC | #2
On 23/08/2023 15:25, kernel test robot wrote:
> Hi Pieter,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on net-next/main]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Pieter-Jansen-van-Vuuren/sfc-introduce-ethernet-pedit-set-action-infrastructure/20230823-192051
> base:   net-next/main
> patch link:    https://lore.kernel.org/r/20230823111725.28090-6-pieter.jansen-van-vuuren%40amd.com
> patch subject: [PATCH net-next 5/6] sfc: introduce pedit add actions on the ipv4 ttl field
> config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230823/202308232244.jYYwKnlV-lkp@intel.com/config)
> compiler: alpha-linux-gcc (GCC) 13.2.0
> reproduce: (https://download.01.org/0day-ci/archive/20230823/202308232244.jYYwKnlV-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202308232244.jYYwKnlV-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>>> drivers/net/ethernet/sfc/tc.c:1073: warning: expecting prototype for efx_tc_mangle(). Prototype was for efx_tc_pedit_add() instead

Sorry, I messed up the kdoc while rebasing here. I will get this fixed in v2.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c
index dc6275dee94a..8ba5816b51f2 100644
--- a/drivers/net/ethernet/sfc/tc.c
+++ b/drivers/net/ethernet/sfc/tc.c
@@ -1067,6 +1067,46 @@  static int efx_tc_complete_mac_mangle(struct efx_nic *efx,
  * earlier partial mangle, consume and apply to @act by calling
  * efx_tc_complete_mac_mangle().
  */
+static int efx_tc_pedit_add(struct efx_nic *efx, struct efx_tc_action_set *act,
+			    const struct flow_action_entry *fa,
+			    struct netlink_ext_ack *extack)
+{
+	switch (fa->mangle.htype) {
+	case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
+		switch (fa->mangle.offset) {
+		case offsetof(struct iphdr, ttl):
+			/* check that pedit applies to ttl only */
+			if (fa->mangle.mask != ~EFX_TC_HDR_TYPE_TTL_MASK)
+				break;
+
+			/* Adding 0xff is equivalent to decrementing the ttl.
+			 * Other added values are not supported.
+			 */
+			if ((fa->mangle.val & EFX_TC_HDR_TYPE_TTL_MASK) != U8_MAX)
+				break;
+
+			/* check that we do not decrement ttl twice */
+			if (!efx_tc_flower_action_order_ok(act,
+							   EFX_TC_AO_DEC_TTL)) {
+				NL_SET_ERR_MSG_MOD(extack, "Unsupported: multiple dec ttl");
+				return -EOPNOTSUPP;
+			}
+			act->do_ttl_dec = 1;
+			return 0;
+		default:
+			break;
+		}
+		break;
+	default:
+		break;
+	}
+
+	NL_SET_ERR_MSG_FMT_MOD(extack,
+			       "Unsupported: ttl add action type %x %x %x/%x",
+			       fa->mangle.htype, fa->mangle.offset,
+			       fa->mangle.val, fa->mangle.mask);
+	return -EOPNOTSUPP;
+}
 
 static int efx_tc_mangle(struct efx_nic *efx, struct efx_tc_action_set *act,
 			 const struct flow_action_entry *fa,
@@ -2013,6 +2053,11 @@  static int efx_tc_flower_replace(struct efx_nic *efx,
 			act->vlan_proto[act->vlan_push] = fa->vlan.proto;
 			act->vlan_push++;
 			break;
+		case FLOW_ACTION_ADD:
+			rc = efx_tc_pedit_add(efx, act, fa, extack);
+			if (rc < 0)
+				goto release;
+			break;
 		case FLOW_ACTION_MANGLE:
 			rc = efx_tc_mangle(efx, act, fa, &mung, extack, &match);
 			if (rc < 0)