octeontx2-pf: TC_MATCHALL egress ratelimiting offload
[linux-2.6-microblaze.git] / drivers / net / ethernet / marvell / octeontx2 / nic / otx2_common.h
index a518c22..45730d0 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
 #include <linux/soc/marvell/octeontx2/asm.h>
+#include <net/pkt_cls.h>
 
 #include <mbox.h>
 #include <npc.h>
@@ -264,6 +265,7 @@ struct otx2_flow_config {
 #define OTX2_MAX_NTUPLE_FLOWS  32
 #define OTX2_MAX_UNICAST_FLOWS 8
 #define OTX2_MAX_VLAN_FLOWS    1
+#define OTX2_MAX_TC_FLOWS      OTX2_MAX_NTUPLE_FLOWS
 #define OTX2_MCAM_COUNT                (OTX2_MAX_NTUPLE_FLOWS + \
                                 OTX2_MAX_UNICAST_FLOWS + \
                                 OTX2_MAX_VLAN_FLOWS)
@@ -274,10 +276,20 @@ struct otx2_flow_config {
 #define OTX2_PER_VF_VLAN_FLOWS 2 /* rx+tx per VF */
 #define OTX2_VF_VLAN_RX_INDEX  0
 #define OTX2_VF_VLAN_TX_INDEX  1
+       u32                     tc_flower_offset;
        u32                     ntuple_max_flows;
+       u32                     tc_max_flows;
        struct list_head        flow_list;
 };
 
+struct otx2_tc_info {
+       /* hash table to store TC offloaded flows */
+       struct rhashtable               flow_table;
+       struct rhashtable_params        flow_ht_params;
+       DECLARE_BITMAP(tc_entries_bitmap, OTX2_MAX_TC_FLOWS);
+       unsigned long                   num_entries;
+};
+
 struct dev_hw_ops {
        int     (*sq_aq_init)(void *dev, u16 qidx, u16 sqb_aura);
        void    (*sqe_flush)(void *dev, struct otx2_snd_queue *sq,
@@ -305,6 +317,8 @@ struct otx2_nic {
 #define OTX2_FLAG_PF_SHUTDOWN                  BIT_ULL(8)
 #define OTX2_FLAG_RX_PAUSE_ENABLED             BIT_ULL(9)
 #define OTX2_FLAG_TX_PAUSE_ENABLED             BIT_ULL(10)
+#define OTX2_FLAG_TC_FLOWER_SUPPORT            BIT_ULL(11)
+#define OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED   BIT_ULL(12)
        u64                     flags;
 
        struct otx2_qset        qset;
@@ -347,6 +361,7 @@ struct otx2_nic {
        struct hwtstamp_config  tstamp;
 
        struct otx2_flow_config *flow_cfg;
+       struct otx2_tc_info     tc_info;
 };
 
 static inline bool is_otx2_lbkvf(struct pci_dev *pdev)
@@ -802,4 +817,9 @@ int otx2_add_macfilter(struct net_device *netdev, const u8 *mac);
 int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable);
 int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf);
 u16 otx2_get_max_mtu(struct otx2_nic *pfvf);
+/* tc support */
+int otx2_init_tc(struct otx2_nic *nic);
+void otx2_shutdown_tc(struct otx2_nic *nic);
+int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,
+                 void *type_data);
 #endif /* OTX2_COMMON_H */