mlxsw: pci: Extract cookie index for ACL discard trap packets
authorJiri Pirko <jiri@mellanox.com>
Tue, 25 Feb 2020 10:45:24 +0000 (11:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Feb 2020 19:05:55 +0000 (11:05 -0800)
In case the received packet comes in due to one of ACL discard traps,
take the user_def_val_orig_pkt_len field from CQE and store it
in skb->cb as ACL cookie index.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/pci.c
drivers/net/ethernet/mellanox/mlxsw/pci_hw.h

index 00e44e7..4622682 100644 (file)
@@ -473,7 +473,10 @@ enum mlxsw_devlink_param_id {
 };
 
 struct mlxsw_skb_cb {
-       struct mlxsw_tx_info tx_info;
+       union {
+               struct mlxsw_tx_info tx_info;
+               u32 cookie_index; /* Only used during receive */
+       };
 };
 
 static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
index 914c33e..67ee0da 100644 (file)
@@ -575,6 +575,15 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
 
        rx_info.trap_id = mlxsw_pci_cqe_trap_id_get(cqe);
 
+       if (rx_info.trap_id == MLXSW_TRAP_ID_DISCARD_INGRESS_ACL ||
+           rx_info.trap_id == MLXSW_TRAP_ID_DISCARD_EGRESS_ACL) {
+               u32 cookie_index = 0;
+
+               if (mlxsw_pci->max_cqe_ver >= MLXSW_PCI_CQE_V2)
+                       cookie_index = mlxsw_pci_cqe2_user_def_val_orig_pkt_len_get(cqe);
+               mlxsw_skb_cb(skb)->cookie_index = cookie_index;
+       }
+
        byte_count = mlxsw_pci_cqe_byte_count_get(cqe);
        if (mlxsw_pci_cqe_crc_get(cqe_v, cqe))
                byte_count -= ETH_FCS_LEN;
index cf74346..ea7ec9d 100644 (file)
@@ -208,6 +208,11 @@ MLXSW_ITEM32(pci, cqe0, dqn, 0x0C, 1, 5);
 MLXSW_ITEM32(pci, cqe12, dqn, 0x0C, 1, 6);
 mlxsw_pci_cqe_item_helpers(dqn, 0, 12, 12);
 
+/* pci_cqe_user_def_val_orig_pkt_len
+ * When trap_id is an ACL: User defined value from policy engine action.
+ */
+MLXSW_ITEM32(pci, cqe2, user_def_val_orig_pkt_len, 0x14, 0, 20);
+
 /* pci_cqe_owner
  * Ownership bit.
  */