]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ice: change q_index variable type to s16 to store -1 value
authorMateusz Polchlopek <mateusz.polchlopek@intel.com>
Mon, 28 Oct 2024 16:59:22 +0000 (12:59 -0400)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 4 Nov 2024 21:09:33 +0000 (13:09 -0800)
Fix Flow Director not allowing to re-map traffic to 0th queue when action
is configured to drop (and vice versa).

The current implementation of ethtool callback in the ice driver forbids
change Flow Director action from 0 to -1 and from -1 to 0 with an error,
e.g:

 # ethtool -U eth2 flow-type tcp4 src-ip 1.1.1.1 loc 1 action 0
 # ethtool -U eth2 flow-type tcp4 src-ip 1.1.1.1 loc 1 action -1
 rmgr: Cannot insert RX class rule: Invalid argument

We set the value of `u16 q_index = 0` at the beginning of the function
ice_set_fdir_input_set(). In case of "drop traffic" action (which is
equal to -1 in ethtool) we store the 0 value. Later, when want to change
traffic rule to redirect to queue with index 0 it returns an error
caused by duplicate found.

Fix this behaviour by change of the type of field `q_index` from u16 to s16
in `struct ice_fdir_fltr`. This allows to store -1 in the field in case
of "drop traffic" action. What is more, change the variable type in the
function ice_set_fdir_input_set() and assign at the beginning the new
`#define ICE_FDIR_NO_QUEUE_IDX` which is -1. Later, if the action is set
to another value (point specific queue index) the variable value is
overwritten in the function.

Fixes: cac2a27cd9ab ("ice: Support IPv4 Flow Director filters")
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c
drivers/net/ethernet/intel/ice/ice_fdir.h

index 5412eff8ef233f65d59b936f9254ede4b6c349fb..ee9862ddfe15e0d9989e2492e39e71b54078e2d6 100644 (file)
@@ -1830,11 +1830,12 @@ static int
 ice_set_fdir_input_set(struct ice_vsi *vsi, struct ethtool_rx_flow_spec *fsp,
                       struct ice_fdir_fltr *input)
 {
-       u16 dest_vsi, q_index = 0;
+       s16 q_index = ICE_FDIR_NO_QUEUE_IDX;
        u16 orig_q_index = 0;
        struct ice_pf *pf;
        struct ice_hw *hw;
        int flow_type;
+       u16 dest_vsi;
        u8 dest_ctl;
 
        if (!vsi || !fsp || !input)
index ab5b118daa2da676b335743fa8bbebfea2071bcd..820023c0271fd5d1dbe2d56fa2c63509b74be319 100644 (file)
@@ -53,6 +53,8 @@
  */
 #define ICE_FDIR_IPV4_PKT_FLAG_MF              0x20
 
+#define ICE_FDIR_NO_QUEUE_IDX                  -1
+
 enum ice_fltr_prgm_desc_dest {
        ICE_FLTR_PRGM_DESC_DEST_DROP_PKT,
        ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX,
@@ -186,7 +188,7 @@ struct ice_fdir_fltr {
        u16 flex_fltr;
 
        /* filter control */
-       u16 q_index;
+       s16 q_index;
        u16 orig_q_index;
        u16 dest_vsi;
        u8 dest_ctl;