diff mbox series

[net-next,3/6] sfc: add decrement ttl by offloading set ipv4 ttl actions

Message ID 20230823111725.28090-4-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 fail Errors and warnings before: 1331 this patch: 1332
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang fail Errors and warnings before: 1353 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 fail Errors and warnings before: 1354 this patch: 1355
netdev/checkpatch warning WARNING: line length of 84 exceeds 80 columns
netdev/kdoc fail Errors and warnings before: 0 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
Offload pedit set ipv4 ttl field, where the ttl field has already been
matched and the new value is one less, by translating it to a decrement.

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/mae.c |  6 ++-
 drivers/net/ethernet/sfc/tc.c  | 74 +++++++++++++++++++++++++++++++++-
 drivers/net/ethernet/sfc/tc.h  |  2 +
 3 files changed, 78 insertions(+), 4 deletions(-)

Comments

kernel test robot Aug. 23, 2023, 2:49 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-4-pieter.jansen-van-vuuren%40amd.com
patch subject: [PATCH net-next 3/6] sfc: add decrement ttl by offloading set ipv4 ttl actions
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230823/202308232237.WkCLb0PW-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230823/202308232237.WkCLb0PW-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/202308232237.WkCLb0PW-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/sfc/tc.c:1074: warning: Function parameter or member 'match' not described in 'efx_tc_mangle'


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

12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1054  
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1055  /**
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1056   * efx_tc_mangle() - handle a single 32-bit (or less) pedit
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1057   * @efx: NIC we're installing a flow rule on
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1058   * @act: action set (cursor) to update
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1059   * @fa:          FLOW_ACTION_MANGLE action metadata
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1060   * @mung:        accumulator for partial mangles
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1061   * @extack:      netlink extended ack for reporting errors
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1062   *
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1063   * Identify the fields written by a FLOW_ACTION_MANGLE, and record
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1064   * the partial mangle state in @mung.  If this mangle completes an
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1065   * earlier partial mangle, consume and apply to @act by calling
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1066   * efx_tc_complete_mac_mangle().
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1067   */
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1068  
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1069  static int efx_tc_mangle(struct efx_nic *efx, struct efx_tc_action_set *act,
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1070  			 const struct flow_action_entry *fa,
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1071  			 struct efx_tc_mangler_state *mung,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1072  			 struct netlink_ext_ack *extack,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1073  			 struct efx_tc_match *match)
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23 @1074  {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1075  	__le32 mac32;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1076  	__le16 mac16;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1077  	u8 tr_ttl;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1078  
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1079  	switch (fa->mangle.htype) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1080  	case FLOW_ACT_MANGLE_HDR_TYPE_ETH:
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1081  		BUILD_BUG_ON(offsetof(struct ethhdr, h_dest) != 0);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1082  		BUILD_BUG_ON(offsetof(struct ethhdr, h_source) != 6);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1083  		if (!efx_tc_flower_action_order_ok(act, EFX_TC_AO_PEDIT_MAC_ADDRS)) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1084  			NL_SET_ERR_MSG_MOD(extack,
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1085  					   "Pedit mangle mac action violates action order");
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1086  			return -EOPNOTSUPP;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1087  		}
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1088  		switch (fa->mangle.offset) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1089  		case 0:
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1090  			if (fa->mangle.mask) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1091  				NL_SET_ERR_MSG_FMT_MOD(extack,
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1092  						       "Unsupported: mask (%#x) of eth.dst32 mangle",
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1093  						       fa->mangle.mask);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1094  				return -EOPNOTSUPP;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1095  			}
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1096  			/* Ethernet address is little-endian */
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1097  			mac32 = cpu_to_le32(fa->mangle.val);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1098  			memcpy(mung->dst_mac, &mac32, sizeof(mac32));
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1099  			mung->dst_mac_32 = 1;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1100  			return efx_tc_complete_mac_mangle(efx, act, mung, extack);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1101  		case 4:
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1102  			if (fa->mangle.mask == 0xffff) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1103  				mac16 = cpu_to_le16(fa->mangle.val >> 16);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1104  				memcpy(mung->src_mac, &mac16, sizeof(mac16));
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1105  				mung->src_mac_16 = 1;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1106  			} else if (fa->mangle.mask == 0xffff0000) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1107  				mac16 = cpu_to_le16((u16)fa->mangle.val);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1108  				memcpy(mung->dst_mac + 4, &mac16, sizeof(mac16));
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1109  				mung->dst_mac_16 = 1;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1110  			} else {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1111  				NL_SET_ERR_MSG_FMT_MOD(extack,
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1112  						       "Unsupported: mask (%#x) of eth+4 mangle is not high or low 16b",
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1113  						       fa->mangle.mask);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1114  				return -EOPNOTSUPP;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1115  			}
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1116  			return efx_tc_complete_mac_mangle(efx, act, mung, extack);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1117  		case 8:
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1118  			if (fa->mangle.mask) {
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1119  				NL_SET_ERR_MSG_FMT_MOD(extack,
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1120  						       "Unsupported: mask (%#x) of eth.src32 mangle",
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1121  						       fa->mangle.mask);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1122  				return -EOPNOTSUPP;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1123  			}
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1124  			mac32 = cpu_to_le32(fa->mangle.val);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1125  			memcpy(mung->src_mac + 2, &mac32, sizeof(mac32));
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1126  			mung->src_mac_32 = 1;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1127  			return efx_tc_complete_mac_mangle(efx, act, mung, extack);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1128  		default:
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1129  			NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported: mangle eth+%u %x/%x",
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1130  					       fa->mangle.offset, fa->mangle.val, fa->mangle.mask);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1131  			return -EOPNOTSUPP;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1132  		}
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1133  		break;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1134  	case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1135  		switch (fa->mangle.offset) {
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1136  		case offsetof(struct iphdr, ttl):
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1137  			/* we currently only support pedit IP4 when it applies
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1138  			 * to TTL and then only when it can be achieved with a
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1139  			 * decrement ttl action
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1140  			 */
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1141  
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1142  			/* check that pedit applies to ttl only */
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1143  			if (fa->mangle.mask != ~EFX_TC_HDR_TYPE_TTL_MASK) {
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1144  				NL_SET_ERR_MSG_FMT_MOD(extack,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1145  						       "Unsupported: mask (%#x) out of range, only support mangle action on ipv4.ttl",
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1146  						       fa->mangle.mask);
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1147  				return -EOPNOTSUPP;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1148  			}
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1149  
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1150  			/* we can only convert to a dec ttl when we have an
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1151  			 * exact match on the ttl field
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1152  			 */
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1153  			if (match->mask.ip_ttl != U8_MAX) {
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1154  				NL_SET_ERR_MSG_FMT_MOD(extack,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1155  						       "Unsupported: only support mangle ipv4.ttl when we have an exact match on ttl, mask used for match (%#x)",
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1156  						       match->mask.ip_ttl);
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1157  				return -EOPNOTSUPP;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1158  			}
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1159  
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1160  			/* check that we don't try to decrement 0, which equates
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1161  			 * to setting the ttl to 0xff
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1162  			 */
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1163  			if (match->value.ip_ttl == 0) {
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1164  				NL_SET_ERR_MSG_MOD(extack,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1165  						   "Unsupported: we cannot decrement ttl past 0");
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1166  				return -EOPNOTSUPP;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1167  			}
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1168  
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1169  			/* check that we do not decrement ttl twice */
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1170  			if (!efx_tc_flower_action_order_ok(act,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1171  							   EFX_TC_AO_DEC_TTL)) {
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1172  				NL_SET_ERR_MSG_MOD(extack,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1173  						   "Unsupported: multiple dec ttl");
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1174  				return -EOPNOTSUPP;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1175  			}
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1176  
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1177  			/* check pedit can be achieved with decrement action */
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1178  			tr_ttl = match->value.ip_ttl - 1;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1179  			if ((fa->mangle.val & EFX_TC_HDR_TYPE_TTL_MASK) == tr_ttl) {
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1180  				act->do_ttl_dec = 1;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1181  				return 0;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1182  			}
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1183  
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1184  			fallthrough;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1185  		default:
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1186  			NL_SET_ERR_MSG_FMT_MOD(extack,
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1187  					       "Unsupported: only support mangle on the ttl field (offset is %u)",
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1188  					       fa->mangle.offset);
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1189  			return -EOPNOTSUPP;
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1190  		}
b1a793d7986335 Pieter Jansen van Vuuren 2023-08-23  1191  		break;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1192  	default:
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1193  		NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled mangle htype %u for action rule",
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1194  				       fa->mangle.htype);
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1195  		return -EOPNOTSUPP;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1196  	}
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1197  	return 0;
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1198  }
12322dfaf48dc2 Pieter Jansen van Vuuren 2023-08-23  1199
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c
index a7ad7ab8c5f4..c3e2b4a21d10 100644
--- a/drivers/net/ethernet/sfc/mae.c
+++ b/drivers/net/ethernet/sfc/mae.c
@@ -1291,10 +1291,12 @@  int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act)
 	size_t outlen;
 	int rc;
 
-	MCDI_POPULATE_DWORD_3(inbuf, MAE_ACTION_SET_ALLOC_IN_FLAGS,
+	MCDI_POPULATE_DWORD_4(inbuf, MAE_ACTION_SET_ALLOC_IN_FLAGS,
 			      MAE_ACTION_SET_ALLOC_IN_VLAN_PUSH, act->vlan_push,
 			      MAE_ACTION_SET_ALLOC_IN_VLAN_POP, act->vlan_pop,
-			      MAE_ACTION_SET_ALLOC_IN_DECAP, act->decap);
+			      MAE_ACTION_SET_ALLOC_IN_DECAP, act->decap,
+			      MAE_ACTION_SET_ALLOC_IN_DO_DECR_IP_TTL,
+			      act->do_ttl_dec);
 
 	if (act->src_mac)
 		MCDI_SET_DWORD(inbuf, MAE_ACTION_SET_ALLOC_IN_SRC_MAC_ID,
diff --git a/drivers/net/ethernet/sfc/tc.c b/drivers/net/ethernet/sfc/tc.c
index 47bf59529a46..03205789dd6a 100644
--- a/drivers/net/ethernet/sfc/tc.c
+++ b/drivers/net/ethernet/sfc/tc.c
@@ -31,6 +31,7 @@  enum efx_encap_type efx_tc_indr_netdev_type(struct net_device *net_dev)
 	return EFX_ENCAP_TYPE_NONE;
 }
 
+#define EFX_TC_HDR_TYPE_TTL_MASK ((u32)0xff)
 #define EFX_EFV_PF	NULL
 /* Look up the representor information (efv) for a device.
  * May return NULL for the PF (us), or an error pointer for a device that
@@ -757,6 +758,7 @@  static const char *efx_tc_encap_type_name(enum efx_encap_type typ)
 /* For details of action order constraints refer to SF-123102-TC-1§12.6.1 */
 enum efx_tc_action_order {
 	EFX_TC_AO_DECAP,
+	EFX_TC_AO_DEC_TTL,
 	EFX_TC_AO_PEDIT_MAC_ADDRS,
 	EFX_TC_AO_VLAN_POP,
 	EFX_TC_AO_VLAN_PUSH,
@@ -777,6 +779,10 @@  static bool efx_tc_flower_action_order_ok(const struct efx_tc_action_set *act,
 		 */
 		if (act->dst_mac || act->src_mac)
 			return false;
+
+		/* Decrementing ttl must not happen before DECAP */
+		if (act->do_ttl_dec)
+			return false;
 		fallthrough;
 	case EFX_TC_AO_VLAN_POP:
 		if (act->vlan_pop >= 2)
@@ -803,6 +809,10 @@  static bool efx_tc_flower_action_order_ok(const struct efx_tc_action_set *act,
 		fallthrough;
 	case EFX_TC_AO_DELIVER:
 		return !act->deliver;
+	case EFX_TC_AO_DEC_TTL:
+		if (act->encap_md)
+			return false;
+		return !act->do_ttl_dec;
 	default:
 		/* Bad caller.  Whatever they wanted to do, say they can't. */
 		WARN_ON_ONCE(1);
@@ -1059,10 +1069,12 @@  static int efx_tc_complete_mac_mangle(struct efx_nic *efx,
 static int efx_tc_mangle(struct efx_nic *efx, struct efx_tc_action_set *act,
 			 const struct flow_action_entry *fa,
 			 struct efx_tc_mangler_state *mung,
-			 struct netlink_ext_ack *extack)
+			 struct netlink_ext_ack *extack,
+			 struct efx_tc_match *match)
 {
 	__le32 mac32;
 	__le16 mac16;
+	u8 tr_ttl;
 
 	switch (fa->mangle.htype) {
 	case FLOW_ACT_MANGLE_HDR_TYPE_ETH:
@@ -1119,6 +1131,64 @@  static int efx_tc_mangle(struct efx_nic *efx, struct efx_tc_action_set *act,
 			return -EOPNOTSUPP;
 		}
 		break;
+	case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
+		switch (fa->mangle.offset) {
+		case offsetof(struct iphdr, ttl):
+			/* we currently only support pedit IP4 when it applies
+			 * to TTL and then only when it can be achieved with a
+			 * decrement ttl action
+			 */
+
+			/* check that pedit applies to ttl only */
+			if (fa->mangle.mask != ~EFX_TC_HDR_TYPE_TTL_MASK) {
+				NL_SET_ERR_MSG_FMT_MOD(extack,
+						       "Unsupported: mask (%#x) out of range, only support mangle action on ipv4.ttl",
+						       fa->mangle.mask);
+				return -EOPNOTSUPP;
+			}
+
+			/* we can only convert to a dec ttl when we have an
+			 * exact match on the ttl field
+			 */
+			if (match->mask.ip_ttl != U8_MAX) {
+				NL_SET_ERR_MSG_FMT_MOD(extack,
+						       "Unsupported: only support mangle ipv4.ttl when we have an exact match on ttl, mask used for match (%#x)",
+						       match->mask.ip_ttl);
+				return -EOPNOTSUPP;
+			}
+
+			/* check that we don't try to decrement 0, which equates
+			 * to setting the ttl to 0xff
+			 */
+			if (match->value.ip_ttl == 0) {
+				NL_SET_ERR_MSG_MOD(extack,
+						   "Unsupported: we cannot decrement ttl past 0");
+				return -EOPNOTSUPP;
+			}
+
+			/* 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;
+			}
+
+			/* check pedit can be achieved with decrement action */
+			tr_ttl = match->value.ip_ttl - 1;
+			if ((fa->mangle.val & EFX_TC_HDR_TYPE_TTL_MASK) == tr_ttl) {
+				act->do_ttl_dec = 1;
+				return 0;
+			}
+
+			fallthrough;
+		default:
+			NL_SET_ERR_MSG_FMT_MOD(extack,
+					       "Unsupported: only support mangle on the ttl field (offset is %u)",
+					       fa->mangle.offset);
+			return -EOPNOTSUPP;
+		}
+		break;
 	default:
 		NL_SET_ERR_MSG_FMT_MOD(extack, "Unhandled mangle htype %u for action rule",
 				       fa->mangle.htype);
@@ -1885,7 +1955,7 @@  static int efx_tc_flower_replace(struct efx_nic *efx,
 			act->vlan_push++;
 			break;
 		case FLOW_ACTION_MANGLE:
-			rc = efx_tc_mangle(efx, act, fa, &mung, extack);
+			rc = efx_tc_mangle(efx, act, fa, &mung, extack, &match);
 			if (rc < 0)
 				goto release;
 			break;
diff --git a/drivers/net/ethernet/sfc/tc.h b/drivers/net/ethernet/sfc/tc.h
index 91705411e5c5..d50f45b444a9 100644
--- a/drivers/net/ethernet/sfc/tc.h
+++ b/drivers/net/ethernet/sfc/tc.h
@@ -48,6 +48,7 @@  struct efx_tc_encap_action; /* see tc_encap_actions.h */
  * @vlan_push: the number of vlan headers to push
  * @vlan_pop: the number of vlan headers to pop
  * @decap: used to indicate a tunnel header decapsulation should take place
+ * @do_ttl_dec: used to indicate IP TTL / Hop Limit should be decremented
  * @deliver: used to indicate a deliver action should take place
  * @vlan_tci: tci fields for vlan push actions
  * @vlan_proto: ethernet types for vlan push actions
@@ -67,6 +68,7 @@  struct efx_tc_action_set {
 	u16 vlan_push:2;
 	u16 vlan_pop:2;
 	u16 decap:1;
+	u16 do_ttl_dec:1;
 	u16 deliver:1;
 	__be16 vlan_tci[2];
 	__be16 vlan_proto[2];