| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* Copyright (C) 2022, Intel Corporation. */ |
| 3 |
|
| 4 |
#ifndef _ICE_VIRTCHNL_H_ |
| 5 |
#define _ICE_VIRTCHNL_H_ |
| 6 |
|
| 7 |
#include <linux/types.h> |
| 8 |
#include <linux/bitops.h> |
| 9 |
#include <linux/if_ether.h> |
| 10 |
#include <linux/avf/virtchnl.h> |
| 11 |
#include "ice_vf_lib.h" |
| 12 |
|
| 13 |
/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ |
| 14 |
#define ICE_MAX_VLAN_PER_VF 8 |
| 15 |
|
| 16 |
#define ICE_DFLT_QUANTA 1024 |
| 17 |
#define ICE_MAX_QUANTA_SIZE 4096 |
| 18 |
#define ICE_MIN_QUANTA_SIZE 256 |
| 19 |
|
| 20 |
#define calc_quanta_desc(x) \ |
| 21 |
max_t(u16, 12, min_t(u16, 63, (((x) + 66) / 132) * 2 + 4)) |
| 22 |
|
| 23 |
/* MAC filters: 1 is reserved for the VF's default/perm_addr/LAA MAC, 1 for |
| 24 |
* broadcast, and 16 for additional unicast/multicast filters |
| 25 |
*/ |
| 26 |
#define ICE_MAX_MACADDR_PER_VF 18 |
| 27 |
#define ICE_FLEX_DESC_RXDID_MAX_NUM 64 |
| 28 |
|
| 29 |
/* Priority to be compared against previous priority from the pipe */ |
| 30 |
#define ICE_RXDID_PRIO 0x03 |
| 31 |
|
| 32 |
/* VFs only get a single VSI. For ice hardware, the VF does not need to know |
| 33 |
* its VSI index. However, the virtchnl interface requires a VSI number, |
| 34 |
* mainly due to legacy hardware. |
| 35 |
* |
| 36 |
* Since the VF doesn't need this information, report a static value to the VF |
| 37 |
* instead of leaking any information about the PF or hardware setup. |
| 38 |
*/ |
| 39 |
#define ICE_VF_VSI_ID 1 |
| 40 |
|
| 41 |
struct ice_virtchnl_ops { |
| 42 |
int (*get_ver_msg)(struct ice_vf *vf, u8 *msg); |
| 43 |
int (*get_vf_res_msg)(struct ice_vf *vf, u8 *msg); |
| 44 |
void (*reset_vf)(struct ice_vf *vf); |
| 45 |
int (*add_mac_addr_msg)(struct ice_vf *vf, u8 *msg); |
| 46 |
int (*del_mac_addr_msg)(struct ice_vf *vf, u8 *msg); |
| 47 |
int (*cfg_qs_msg)(struct ice_vf *vf, u8 *msg); |
| 48 |
int (*ena_qs_msg)(struct ice_vf *vf, u8 *msg); |
| 49 |
int (*dis_qs_msg)(struct ice_vf *vf, u8 *msg); |
| 50 |
int (*request_qs_msg)(struct ice_vf *vf, u8 *msg); |
| 51 |
int (*cfg_irq_map_msg)(struct ice_vf *vf, u8 *msg); |
| 52 |
int (*config_rss_key)(struct ice_vf *vf, u8 *msg); |
| 53 |
int (*config_rss_lut)(struct ice_vf *vf, u8 *msg); |
| 54 |
int (*config_rss_hfunc)(struct ice_vf *vf, u8 *msg); |
| 55 |
int (*get_stats_msg)(struct ice_vf *vf, u8 *msg); |
| 56 |
int (*cfg_promiscuous_mode_msg)(struct ice_vf *vf, u8 *msg); |
| 57 |
int (*add_vlan_msg)(struct ice_vf *vf, u8 *msg); |
| 58 |
int (*remove_vlan_msg)(struct ice_vf *vf, u8 *msg); |
| 59 |
int (*query_rxdid)(struct ice_vf *vf); |
| 60 |
int (*get_rss_hashcfg)(struct ice_vf *vf); |
| 61 |
int (*set_rss_hashcfg)(struct ice_vf *vf, u8 *msg); |
| 62 |
int (*ena_vlan_stripping)(struct ice_vf *vf); |
| 63 |
int (*dis_vlan_stripping)(struct ice_vf *vf); |
| 64 |
int (*handle_rss_cfg_msg)(struct ice_vf *vf, u8 *msg, bool add); |
| 65 |
int (*add_fdir_fltr_msg)(struct ice_vf *vf, u8 *msg); |
| 66 |
int (*del_fdir_fltr_msg)(struct ice_vf *vf, u8 *msg); |
| 67 |
int (*get_offload_vlan_v2_caps)(struct ice_vf *vf); |
| 68 |
int (*add_vlan_v2_msg)(struct ice_vf *vf, u8 *msg); |
| 69 |
int (*remove_vlan_v2_msg)(struct ice_vf *vf, u8 *msg); |
| 70 |
int (*ena_vlan_stripping_v2_msg)(struct ice_vf *vf, u8 *msg); |
| 71 |
int (*dis_vlan_stripping_v2_msg)(struct ice_vf *vf, u8 *msg); |
| 72 |
int (*ena_vlan_insertion_v2_msg)(struct ice_vf *vf, u8 *msg); |
| 73 |
int (*dis_vlan_insertion_v2_msg)(struct ice_vf *vf, u8 *msg); |
| 74 |
int (*get_qos_caps)(struct ice_vf *vf); |
| 75 |
int (*cfg_q_tc_map)(struct ice_vf *vf, u8 *msg); |
| 76 |
int (*cfg_q_bw)(struct ice_vf *vf, u8 *msg); |
| 77 |
int (*cfg_q_quanta)(struct ice_vf *vf, u8 *msg); |
| 78 |
int (*get_ptp_cap)(struct ice_vf *vf, |
| 79 |
const struct virtchnl_ptp_caps *msg); |
| 80 |
int (*get_phc_time)(struct ice_vf *vf); |
| 81 |
}; |
| 82 |
|
| 83 |
#ifdef CONFIG_PCI_IOV |
| 84 |
void ice_virtchnl_set_dflt_ops(struct ice_vf *vf); |
| 85 |
void ice_virtchnl_set_repr_ops(struct ice_vf *vf); |
| 86 |
void ice_vc_notify_vf_link_state(struct ice_vf *vf); |
| 87 |
void ice_vc_notify_link_state(struct ice_pf *pf); |
| 88 |
void ice_vc_notify_reset(struct ice_pf *pf); |
| 89 |
int |
| 90 |
ice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode, |
| 91 |
enum virtchnl_status_code v_retval, u8 *msg, u16 msglen); |
| 92 |
bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id); |
| 93 |
void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event, |
| 94 |
struct ice_mbx_data *mbxdata); |
| 95 |
void ice_vf_ena_rxq_interrupt(struct ice_vsi *vsi, u32 q_idx); |
| 96 |
void ice_vf_ena_txq_interrupt(struct ice_vsi *vsi, u32 q_idx); |
| 97 |
int ice_vf_ena_vlan_promisc(struct ice_vf *vf, struct ice_vsi *vsi, |
| 98 |
struct ice_vlan *vlan); |
| 99 |
bool ice_is_vlan_promisc_allowed(struct ice_vf *vf); |
| 100 |
#else /* CONFIG_PCI_IOV */ |
| 101 |
static inline void ice_virtchnl_set_dflt_ops(struct ice_vf *vf) { } |
| 102 |
static inline void ice_virtchnl_set_repr_ops(struct ice_vf *vf) { } |
| 103 |
static inline void ice_vc_notify_vf_link_state(struct ice_vf *vf) { } |
| 104 |
static inline void ice_vc_notify_link_state(struct ice_pf *pf) { } |
| 105 |
static inline void ice_vc_notify_reset(struct ice_pf *pf) { } |
| 106 |
static inline void ice_vf_ena_rxq_interrupt(struct ice_vsi *vsi, u32 q_idx) { } |
| 107 |
static inline void ice_vf_ena_txq_interrupt(struct ice_vsi *vsi, u32 q_idx) { } |
| 108 |
|
| 109 |
static inline int ice_vf_ena_vlan_promisc(struct ice_vf *vf, |
| 110 |
struct ice_vsi *vsi, |
| 111 |
struct ice_vlan *vlan) |
| 112 |
{ |
| 113 |
return -EOPNOTSUPP; |
| 114 |
} |
| 115 |
|
| 116 |
static inline bool ice_is_vlan_promisc_allowed(struct ice_vf *vf) |
| 117 |
{ |
| 118 |
return false; |
| 119 |
} |
| 120 |
|
| 121 |
static inline int |
| 122 |
ice_vc_send_msg_to_vf(struct ice_vf *vf, u32 v_opcode, |
| 123 |
enum virtchnl_status_code v_retval, u8 *msg, u16 msglen) |
| 124 |
{ |
| 125 |
return -EOPNOTSUPP; |
| 126 |
} |
| 127 |
|
| 128 |
static inline bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id) |
| 129 |
{ |
| 130 |
return false; |
| 131 |
} |
| 132 |
|
| 133 |
static inline void |
| 134 |
ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event, |
| 135 |
struct ice_mbx_data *mbxdata) |
| 136 |
{ |
| 137 |
} |
| 138 |
#endif /* !CONFIG_PCI_IOV */ |
| 139 |
|
| 140 |
#endif /* _ICE_VIRTCHNL_H_ */ |