162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright (C) 2022, Intel Corporation. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _ICE_VIRTCHNL_H_ 562306a36Sopenharmony_ci#define _ICE_VIRTCHNL_H_ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/types.h> 862306a36Sopenharmony_ci#include <linux/bitops.h> 962306a36Sopenharmony_ci#include <linux/if_ether.h> 1062306a36Sopenharmony_ci#include <linux/avf/virtchnl.h> 1162306a36Sopenharmony_ci#include "ice_vf_lib.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ 1462306a36Sopenharmony_ci#define ICE_MAX_VLAN_PER_VF 8 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* MAC filters: 1 is reserved for the VF's default/perm_addr/LAA MAC, 1 for 1762306a36Sopenharmony_ci * broadcast, and 16 for additional unicast/multicast filters 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_ci#define ICE_MAX_MACADDR_PER_VF 18 2062306a36Sopenharmony_ci#define ICE_FLEX_DESC_RXDID_MAX_NUM 64 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_cistruct ice_virtchnl_ops { 2362306a36Sopenharmony_ci int (*get_ver_msg)(struct ice_vf *vf, u8 *msg); 2462306a36Sopenharmony_ci int (*get_vf_res_msg)(struct ice_vf *vf, u8 *msg); 2562306a36Sopenharmony_ci void (*reset_vf)(struct ice_vf *vf); 2662306a36Sopenharmony_ci int (*add_mac_addr_msg)(struct ice_vf *vf, u8 *msg); 2762306a36Sopenharmony_ci int (*del_mac_addr_msg)(struct ice_vf *vf, u8 *msg); 2862306a36Sopenharmony_ci int (*cfg_qs_msg)(struct ice_vf *vf, u8 *msg); 2962306a36Sopenharmony_ci int (*ena_qs_msg)(struct ice_vf *vf, u8 *msg); 3062306a36Sopenharmony_ci int (*dis_qs_msg)(struct ice_vf *vf, u8 *msg); 3162306a36Sopenharmony_ci int (*request_qs_msg)(struct ice_vf *vf, u8 *msg); 3262306a36Sopenharmony_ci int (*cfg_irq_map_msg)(struct ice_vf *vf, u8 *msg); 3362306a36Sopenharmony_ci int (*config_rss_key)(struct ice_vf *vf, u8 *msg); 3462306a36Sopenharmony_ci int (*config_rss_lut)(struct ice_vf *vf, u8 *msg); 3562306a36Sopenharmony_ci int (*get_stats_msg)(struct ice_vf *vf, u8 *msg); 3662306a36Sopenharmony_ci int (*cfg_promiscuous_mode_msg)(struct ice_vf *vf, u8 *msg); 3762306a36Sopenharmony_ci int (*add_vlan_msg)(struct ice_vf *vf, u8 *msg); 3862306a36Sopenharmony_ci int (*remove_vlan_msg)(struct ice_vf *vf, u8 *msg); 3962306a36Sopenharmony_ci int (*query_rxdid)(struct ice_vf *vf); 4062306a36Sopenharmony_ci int (*get_rss_hena)(struct ice_vf *vf); 4162306a36Sopenharmony_ci int (*set_rss_hena_msg)(struct ice_vf *vf, u8 *msg); 4262306a36Sopenharmony_ci int (*ena_vlan_stripping)(struct ice_vf *vf); 4362306a36Sopenharmony_ci int (*dis_vlan_stripping)(struct ice_vf *vf); 4462306a36Sopenharmony_ci int (*handle_rss_cfg_msg)(struct ice_vf *vf, u8 *msg, bool add); 4562306a36Sopenharmony_ci int (*add_fdir_fltr_msg)(struct ice_vf *vf, u8 *msg); 4662306a36Sopenharmony_ci int (*del_fdir_fltr_msg)(struct ice_vf *vf, u8 *msg); 4762306a36Sopenharmony_ci int (*get_offload_vlan_v2_caps)(struct ice_vf *vf); 4862306a36Sopenharmony_ci int (*add_vlan_v2_msg)(struct ice_vf *vf, u8 *msg); 4962306a36Sopenharmony_ci int (*remove_vlan_v2_msg)(struct ice_vf *vf, u8 *msg); 5062306a36Sopenharmony_ci int (*ena_vlan_stripping_v2_msg)(struct ice_vf *vf, u8 *msg); 5162306a36Sopenharmony_ci int (*dis_vlan_stripping_v2_msg)(struct ice_vf *vf, u8 *msg); 5262306a36Sopenharmony_ci int (*ena_vlan_insertion_v2_msg)(struct ice_vf *vf, u8 *msg); 5362306a36Sopenharmony_ci int (*dis_vlan_insertion_v2_msg)(struct ice_vf *vf, u8 *msg); 5462306a36Sopenharmony_ci}; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#ifdef CONFIG_PCI_IOV 5762306a36Sopenharmony_civoid ice_virtchnl_set_dflt_ops(struct ice_vf *vf); 5862306a36Sopenharmony_civoid ice_virtchnl_set_repr_ops(struct ice_vf *vf); 5962306a36Sopenharmony_civoid ice_vc_notify_vf_link_state(struct ice_vf *vf); 6062306a36Sopenharmony_civoid ice_vc_notify_link_state(struct ice_pf *pf); 6162306a36Sopenharmony_civoid ice_vc_notify_reset(struct ice_pf *pf); 6262306a36Sopenharmony_ciint 6362306a36Sopenharmony_ciice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode, 6462306a36Sopenharmony_ci enum virtchnl_status_code v_retval, u8 *msg, u16 msglen); 6562306a36Sopenharmony_cibool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id); 6662306a36Sopenharmony_civoid ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event, 6762306a36Sopenharmony_ci struct ice_mbx_data *mbxdata); 6862306a36Sopenharmony_ci#else /* CONFIG_PCI_IOV */ 6962306a36Sopenharmony_cistatic inline void ice_virtchnl_set_dflt_ops(struct ice_vf *vf) { } 7062306a36Sopenharmony_cistatic inline void ice_virtchnl_set_repr_ops(struct ice_vf *vf) { } 7162306a36Sopenharmony_cistatic inline void ice_vc_notify_vf_link_state(struct ice_vf *vf) { } 7262306a36Sopenharmony_cistatic inline void ice_vc_notify_link_state(struct ice_pf *pf) { } 7362306a36Sopenharmony_cistatic inline void ice_vc_notify_reset(struct ice_pf *pf) { } 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistatic inline int 7662306a36Sopenharmony_ciice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode, 7762306a36Sopenharmony_ci enum virtchnl_status_code v_retval, u8 *msg, u16 msglen) 7862306a36Sopenharmony_ci{ 7962306a36Sopenharmony_ci return -EOPNOTSUPP; 8062306a36Sopenharmony_ci} 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_cistatic inline bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id) 8362306a36Sopenharmony_ci{ 8462306a36Sopenharmony_ci return false; 8562306a36Sopenharmony_ci} 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_cistatic inline void 8862306a36Sopenharmony_ciice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event, 8962306a36Sopenharmony_ci struct ice_mbx_data *mbxdata) 9062306a36Sopenharmony_ci{ 9162306a36Sopenharmony_ci} 9262306a36Sopenharmony_ci#endif /* !CONFIG_PCI_IOV */ 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#endif /* _ICE_VIRTCHNL_H_ */ 95