Hello Edward Cree, The patch 2245eb0086d8: "sfc: add functions to insert encap matches into the MAE" from Mar 27, 2023, leads to the following Smatch static checker warning: drivers/net/ethernet/sfc/mae.c:1002 efx_mae_register_encap_match() warn: this cast is a no-op drivers/net/ethernet/sfc/mae.c 953 int efx_mae_register_encap_match(struct efx_nic *efx, 954 struct efx_tc_encap_match *encap) 955 { 956 MCDI_DECLARE_BUF(inbuf, MC_CMD_MAE_OUTER_RULE_INSERT_IN_LEN(MAE_ENC_FIELD_PAIRS_LEN)); 957 MCDI_DECLARE_BUF(outbuf, MC_CMD_MAE_OUTER_RULE_INSERT_OUT_LEN); 958 MCDI_DECLARE_STRUCT_PTR(match_crit); 959 size_t outlen; 960 int rc; 961 962 rc = efx_mae_encap_type_to_mae_type(encap->tun_type); 963 if (rc < 0) 964 return rc; 965 match_crit = _MCDI_DWORD(inbuf, MAE_OUTER_RULE_INSERT_IN_FIELD_MATCH_CRITERIA); 966 /* The struct contains IP src and dst, and udp dport. 967 * So we actually need to filter on IP src and dst, L4 dport, and 968 * ipproto == udp. 969 */ 970 MCDI_SET_DWORD(inbuf, MAE_OUTER_RULE_INSERT_IN_ENCAP_TYPE, rc); 971 #ifdef CONFIG_IPV6 972 if (encap->src_ip | encap->dst_ip) { 973 #endif 974 MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_SRC_IP4_BE, 975 encap->src_ip); 976 MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_SRC_IP4_BE_MASK, 977 ~(__be32)0); 978 MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_DST_IP4_BE, 979 encap->dst_ip); 980 MCDI_STRUCT_SET_DWORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_DST_IP4_BE_MASK, 981 ~(__be32)0); ^^^^^^^^^^ The __be32 is unsigned so the result is 0xffffffff and it's never sign extented to 64 bits. 982 MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_ETHER_TYPE_BE, 983 htons(ETH_P_IP)); 984 #ifdef CONFIG_IPV6 985 } else { 986 memcpy(MCDI_STRUCT_PTR(match_crit, MAE_ENC_FIELD_PAIRS_ENC_SRC_IP6_BE), 987 &encap->src_ip6, sizeof(encap->src_ip6)); 988 memset(MCDI_STRUCT_PTR(match_crit, MAE_ENC_FIELD_PAIRS_ENC_SRC_IP6_BE_MASK), 989 0xff, sizeof(encap->src_ip6)); 990 memcpy(MCDI_STRUCT_PTR(match_crit, MAE_ENC_FIELD_PAIRS_ENC_DST_IP6_BE), 991 &encap->dst_ip6, sizeof(encap->dst_ip6)); 992 memset(MCDI_STRUCT_PTR(match_crit, MAE_ENC_FIELD_PAIRS_ENC_DST_IP6_BE_MASK), 993 0xff, sizeof(encap->dst_ip6)); 994 MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_ETHER_TYPE_BE, 995 htons(ETH_P_IPV6)); 996 } 997 #endif 998 MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_ETHER_TYPE_BE_MASK, 999 ~(__be16)0); But for these ones the u16 is type promoted to int and so ~0 is negative one and will be sign extended. The cast does nothing. 1000 MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_L4_DPORT_BE, 1001 encap->udp_dport); --> 1002 MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_L4_DPORT_BE_MASK, 1003 ~(__be16)0); Same. 1004 MCDI_STRUCT_SET_BYTE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_IP_PROTO, IPPROTO_UDP); 1005 MCDI_STRUCT_SET_BYTE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_IP_PROTO_MASK, ~0); 1006 rc = efx_mcdi_rpc(efx, MC_CMD_MAE_OUTER_RULE_INSERT, inbuf, 1007 sizeof(inbuf), outbuf, sizeof(outbuf), &outlen); 1008 if (rc) 1009 return rc; 1010 if (outlen < sizeof(outbuf)) 1011 return -EIO; 1012 encap->fw_id = MCDI_DWORD(outbuf, MAE_OUTER_RULE_INSERT_OUT_OR_ID); 1013 return 0; 1014 } regards, dan carpenter