1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */ 3 4 #ifndef _IONIC_RX_FILTER_H_ 5 #define _IONIC_RX_FILTER_H_ 6 7 #define IONIC_RXQ_INDEX_ANY (0xFFFF) 8 9 enum ionic_filter_state { 10 IONIC_FILTER_STATE_SYNCED, 11 IONIC_FILTER_STATE_NEW, 12 IONIC_FILTER_STATE_OLD, 13 }; 14 15 struct ionic_rx_filter { 16 u32 flow_id; 17 u32 filter_id; 18 u16 rxq_index; 19 enum ionic_filter_state state; 20 struct ionic_rx_filter_add_cmd cmd; 21 struct hlist_node by_hash; 22 struct hlist_node by_id; 23 }; 24 25 #define IONIC_RX_FILTER_HASH_BITS 10 26 #define IONIC_RX_FILTER_HLISTS BIT(IONIC_RX_FILTER_HASH_BITS) 27 #define IONIC_RX_FILTER_HLISTS_MASK (IONIC_RX_FILTER_HLISTS - 1) 28 struct ionic_rx_filters { 29 spinlock_t lock; /* filter list lock */ 30 struct hlist_head by_hash[IONIC_RX_FILTER_HLISTS]; /* by skb hash */ 31 struct hlist_head by_id[IONIC_RX_FILTER_HLISTS]; /* by filter_id */ 32 }; 33 34 void ionic_rx_filter_free(struct ionic_lif *lif, struct ionic_rx_filter *f); 35 void ionic_rx_filter_replay(struct ionic_lif *lif); 36 int ionic_rx_filters_init(struct ionic_lif *lif); 37 void ionic_rx_filters_deinit(struct ionic_lif *lif); 38 int ionic_rx_filter_save(struct ionic_lif *lif, u32 flow_id, u16 rxq_index, 39 u32 hash, struct ionic_admin_ctx *ctx, 40 enum ionic_filter_state state); 41 struct ionic_rx_filter *ionic_rx_filter_by_vlan(struct ionic_lif *lif, u16 vid); 42 struct ionic_rx_filter *ionic_rx_filter_by_addr(struct ionic_lif *lif, const u8 *addr); 43 struct ionic_rx_filter *ionic_rx_filter_rxsteer(struct ionic_lif *lif); 44 void ionic_rx_filter_sync(struct ionic_lif *lif); 45 int ionic_lif_list_addr(struct ionic_lif *lif, const u8 *addr, bool mode); 46 int ionic_rx_filters_need_sync(struct ionic_lif *lif); 47 int ionic_lif_vlan_add(struct ionic_lif *lif, const u16 vid); 48 int ionic_lif_vlan_del(struct ionic_lif *lif, const u16 vid); 49 50 #endif /* _IONIC_RX_FILTER_H_ */ 51