11f7ea1cdSQi Zhang /* SPDX-License-Identifier: GPL-2.0 */
21f7ea1cdSQi Zhang /* Copyright (C) 2021, Intel Corporation. */
31f7ea1cdSQi Zhang 
41f7ea1cdSQi Zhang #ifndef _ICE_VIRTCHNL_FDIR_H_
51f7ea1cdSQi Zhang #define _ICE_VIRTCHNL_FDIR_H_
61f7ea1cdSQi Zhang 
71f7ea1cdSQi Zhang struct ice_vf;
8d6218317SQi Zhang struct ice_pf;
9*109aba47SJacob Keller struct ice_vsi;
10d6218317SQi Zhang 
11d6218317SQi Zhang enum ice_fdir_ctx_stat {
12d6218317SQi Zhang 	ICE_FDIR_CTX_READY,
13d6218317SQi Zhang 	ICE_FDIR_CTX_IRQ,
14d6218317SQi Zhang 	ICE_FDIR_CTX_TIMEOUT,
15d6218317SQi Zhang };
16d6218317SQi Zhang 
17d6218317SQi Zhang struct ice_vf_fdir_ctx {
18d6218317SQi Zhang 	struct timer_list rx_tmr;
19d6218317SQi Zhang 	enum virtchnl_ops v_opcode;
20d6218317SQi Zhang 	enum ice_fdir_ctx_stat stat;
21d6218317SQi Zhang 	union ice_32b_rx_flex_desc rx_desc;
22d6218317SQi Zhang #define ICE_VF_FDIR_CTX_VALID		BIT(0)
23d6218317SQi Zhang 	u32 flags;
24d6218317SQi Zhang 
25d6218317SQi Zhang 	void *conf;
26d6218317SQi Zhang };
271f7ea1cdSQi Zhang 
281f7ea1cdSQi Zhang /* VF FDIR information structure */
291f7ea1cdSQi Zhang struct ice_vf_fdir {
301f7ea1cdSQi Zhang 	u16 fdir_fltr_cnt[ICE_FLTR_PTYPE_MAX][ICE_FD_HW_SEG_MAX];
311f7ea1cdSQi Zhang 	int prof_entry_cnt[ICE_FLTR_PTYPE_MAX][ICE_FD_HW_SEG_MAX];
321f7ea1cdSQi Zhang 	struct ice_fd_hw_prof **fdir_prof;
331f7ea1cdSQi Zhang 
341f7ea1cdSQi Zhang 	struct idr fdir_rule_idr;
351f7ea1cdSQi Zhang 	struct list_head fdir_rule_list;
36d6218317SQi Zhang 
37d6218317SQi Zhang 	spinlock_t ctx_lock; /* protects FDIR context info */
38d6218317SQi Zhang 	struct ice_vf_fdir_ctx ctx_irq;
39d6218317SQi Zhang 	struct ice_vf_fdir_ctx ctx_done;
401f7ea1cdSQi Zhang };
411f7ea1cdSQi Zhang 
42d6218317SQi Zhang #ifdef CONFIG_PCI_IOV
431f7ea1cdSQi Zhang int ice_vc_add_fdir_fltr(struct ice_vf *vf, u8 *msg);
441f7ea1cdSQi Zhang int ice_vc_del_fdir_fltr(struct ice_vf *vf, u8 *msg);
451f7ea1cdSQi Zhang void ice_vf_fdir_init(struct ice_vf *vf);
461f7ea1cdSQi Zhang void ice_vf_fdir_exit(struct ice_vf *vf);
47d6218317SQi Zhang void
48d6218317SQi Zhang ice_vc_fdir_irq_handler(struct ice_vsi *ctrl_vsi,
49d6218317SQi Zhang 			union ice_32b_rx_flex_desc *rx_desc);
50d6218317SQi Zhang void ice_flush_fdir_ctx(struct ice_pf *pf);
51d6218317SQi Zhang #else
52d6218317SQi Zhang static inline void
ice_vc_fdir_irq_handler(struct ice_vsi * ctrl_vsi,union ice_32b_rx_flex_desc * rx_desc)53d6218317SQi Zhang ice_vc_fdir_irq_handler(struct ice_vsi *ctrl_vsi, union ice_32b_rx_flex_desc *rx_desc) { }
ice_flush_fdir_ctx(struct ice_pf * pf)54d6218317SQi Zhang static inline void ice_flush_fdir_ctx(struct ice_pf *pf) { }
55d6218317SQi Zhang #endif /* CONFIG_PCI_IOV */
561f7ea1cdSQi Zhang #endif /* _ICE_VIRTCHNL_FDIR_H_ */
57