| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (c) 2011, Microsoft Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 15 | | - * this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 16 | 5 | * |
|---|
| 17 | 6 | * Authors: |
|---|
| 18 | 7 | * Haiyang Zhang <haiyangz@microsoft.com> |
|---|
| 19 | 8 | * Hank Janssen <hjanssen@microsoft.com> |
|---|
| 20 | 9 | * K. Y. Srinivasan <kys@microsoft.com> |
|---|
| 21 | | - * |
|---|
| 22 | 10 | */ |
|---|
| 23 | 11 | |
|---|
| 24 | 12 | #ifndef _HYPERV_NET_H |
|---|
| .. | .. |
|---|
| 154 | 142 | u32 send_section_size; |
|---|
| 155 | 143 | u32 recv_section_size; |
|---|
| 156 | 144 | |
|---|
| 145 | + struct bpf_prog *bprog; |
|---|
| 146 | + |
|---|
| 157 | 147 | u8 rss_key[NETVSC_HASH_KEYLEN]; |
|---|
| 158 | 148 | }; |
|---|
| 159 | 149 | |
|---|
| .. | .. |
|---|
| 186 | 176 | |
|---|
| 187 | 177 | /* Interface */ |
|---|
| 188 | 178 | struct rndis_message; |
|---|
| 179 | +struct ndis_offload_params; |
|---|
| 189 | 180 | struct netvsc_device; |
|---|
| 181 | +struct netvsc_channel; |
|---|
| 190 | 182 | struct net_device_context; |
|---|
| 191 | 183 | |
|---|
| 192 | 184 | extern u32 netvsc_ring_bytes; |
|---|
| .. | .. |
|---|
| 199 | 191 | struct hv_netvsc_packet *packet, |
|---|
| 200 | 192 | struct rndis_message *rndis_msg, |
|---|
| 201 | 193 | struct hv_page_buffer *page_buffer, |
|---|
| 202 | | - struct sk_buff *skb); |
|---|
| 194 | + struct sk_buff *skb, |
|---|
| 195 | + bool xdp_tx); |
|---|
| 203 | 196 | void netvsc_linkstatus_callback(struct net_device *net, |
|---|
| 204 | 197 | struct rndis_message *resp); |
|---|
| 205 | 198 | int netvsc_recv_callback(struct net_device *net, |
|---|
| 206 | 199 | struct netvsc_device *nvdev, |
|---|
| 207 | | - struct vmbus_channel *channel, |
|---|
| 208 | | - void *data, u32 len, |
|---|
| 209 | | - const struct ndis_tcp_ip_checksum_info *csum_info, |
|---|
| 210 | | - const struct ndis_pkt_8021q_info *vlan); |
|---|
| 200 | + struct netvsc_channel *nvchan); |
|---|
| 211 | 201 | void netvsc_channel_cb(void *context); |
|---|
| 212 | 202 | int netvsc_poll(struct napi_struct *napi, int budget); |
|---|
| 203 | + |
|---|
| 204 | +u32 netvsc_run_xdp(struct net_device *ndev, struct netvsc_channel *nvchan, |
|---|
| 205 | + struct xdp_buff *xdp); |
|---|
| 206 | +unsigned int netvsc_xdp_fraglen(unsigned int len); |
|---|
| 207 | +struct bpf_prog *netvsc_xdp_get(struct netvsc_device *nvdev); |
|---|
| 208 | +int netvsc_xdp_set(struct net_device *dev, struct bpf_prog *prog, |
|---|
| 209 | + struct netlink_ext_ack *extack, |
|---|
| 210 | + struct netvsc_device *nvdev); |
|---|
| 211 | +int netvsc_vf_setxdp(struct net_device *vf_netdev, struct bpf_prog *prog); |
|---|
| 212 | +int netvsc_bpf(struct net_device *dev, struct netdev_bpf *bpf); |
|---|
| 213 | 213 | |
|---|
| 214 | 214 | int rndis_set_subchannel(struct net_device *ndev, |
|---|
| 215 | 215 | struct netvsc_device *nvdev, |
|---|
| .. | .. |
|---|
| 223 | 223 | struct netvsc_device *nvdev); |
|---|
| 224 | 224 | int rndis_filter_set_rss_param(struct rndis_device *rdev, |
|---|
| 225 | 225 | const u8 *key); |
|---|
| 226 | +int rndis_filter_set_offload_params(struct net_device *ndev, |
|---|
| 227 | + struct netvsc_device *nvdev, |
|---|
| 228 | + struct ndis_offload_params *req_offloads); |
|---|
| 226 | 229 | int rndis_filter_receive(struct net_device *ndev, |
|---|
| 227 | 230 | struct netvsc_device *net_dev, |
|---|
| 228 | | - struct vmbus_channel *channel, |
|---|
| 231 | + struct netvsc_channel *nvchan, |
|---|
| 229 | 232 | void *data, u32 buflen); |
|---|
| 230 | 233 | |
|---|
| 231 | 234 | int rndis_filter_set_device_mac(struct netvsc_device *ndev, |
|---|
| .. | .. |
|---|
| 527 | 530 | u64 ieee8021q:1; |
|---|
| 528 | 531 | u64 correlation_id:1; |
|---|
| 529 | 532 | u64 teaming:1; |
|---|
| 533 | + u64 vsubnetid:1; |
|---|
| 534 | + u64 rsc:1; |
|---|
| 530 | 535 | }; |
|---|
| 531 | 536 | }; |
|---|
| 532 | 537 | } __packed; |
|---|
| .. | .. |
|---|
| 830 | 835 | |
|---|
| 831 | 836 | #define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \ |
|---|
| 832 | 837 | NETIF_F_TSO | NETIF_F_IPV6_CSUM | \ |
|---|
| 833 | | - NETIF_F_TSO6) |
|---|
| 838 | + NETIF_F_TSO6 | NETIF_F_LRO | \ |
|---|
| 839 | + NETIF_F_SG | NETIF_F_RXHASH) |
|---|
| 834 | 840 | |
|---|
| 835 | 841 | #define VRSS_SEND_TAB_SIZE 16 /* must be power of 2 */ |
|---|
| 836 | 842 | #define VRSS_CHANNEL_MAX 64 |
|---|
| .. | .. |
|---|
| 838 | 844 | |
|---|
| 839 | 845 | #define RNDIS_MAX_PKT_DEFAULT 8 |
|---|
| 840 | 846 | #define RNDIS_PKT_ALIGN_DEFAULT 8 |
|---|
| 847 | + |
|---|
| 848 | +#define NETVSC_XDP_HDRM 256 |
|---|
| 849 | + |
|---|
| 850 | +#define NETVSC_XFER_HEADER_SIZE(rng_cnt) \ |
|---|
| 851 | + (offsetof(struct vmtransfer_page_packet_header, ranges) + \ |
|---|
| 852 | + (rng_cnt) * sizeof(struct vmtransfer_page_range)) |
|---|
| 841 | 853 | |
|---|
| 842 | 854 | struct multi_send_data { |
|---|
| 843 | 855 | struct sk_buff *skb; /* skb containing the pkt */ |
|---|
| .. | .. |
|---|
| 856 | 868 | u32 next; /* next entry for writing */ |
|---|
| 857 | 869 | }; |
|---|
| 858 | 870 | |
|---|
| 871 | +#define NVSP_RSC_MAX 562 /* Max #RSC frags in a vmbus xfer page pkt */ |
|---|
| 872 | + |
|---|
| 873 | +struct nvsc_rsc { |
|---|
| 874 | + const struct ndis_pkt_8021q_info *vlan; |
|---|
| 875 | + const struct ndis_tcp_ip_checksum_info *csum_info; |
|---|
| 876 | + const u32 *hash_info; |
|---|
| 877 | + u8 is_last; /* last RNDIS msg in a vmtransfer_page */ |
|---|
| 878 | + u32 cnt; /* #fragments in an RSC packet */ |
|---|
| 879 | + u32 pktlen; /* Full packet length */ |
|---|
| 880 | + void *data[NVSP_RSC_MAX]; |
|---|
| 881 | + u32 len[NVSP_RSC_MAX]; |
|---|
| 882 | +}; |
|---|
| 883 | + |
|---|
| 859 | 884 | struct netvsc_stats { |
|---|
| 860 | 885 | u64 packets; |
|---|
| 861 | 886 | u64 bytes; |
|---|
| 862 | 887 | u64 broadcast; |
|---|
| 863 | 888 | u64 multicast; |
|---|
| 889 | + u64 xdp_drop; |
|---|
| 864 | 890 | struct u64_stats_sync syncp; |
|---|
| 865 | 891 | }; |
|---|
| 866 | 892 | |
|---|
| .. | .. |
|---|
| 875 | 901 | unsigned long rx_no_memory; |
|---|
| 876 | 902 | unsigned long stop_queue; |
|---|
| 877 | 903 | unsigned long wake_queue; |
|---|
| 904 | + unsigned long vlan_error; |
|---|
| 878 | 905 | }; |
|---|
| 879 | 906 | |
|---|
| 880 | 907 | struct netvsc_ethtool_pcpu_stats { |
|---|
| .. | .. |
|---|
| 950 | 977 | u32 vf_alloc; |
|---|
| 951 | 978 | /* Serial number of the VF to team with */ |
|---|
| 952 | 979 | u32 vf_serial; |
|---|
| 980 | + /* completion variable to confirm vf association */ |
|---|
| 981 | + struct completion vf_add; |
|---|
| 982 | + /* Is the current data path through the VF NIC? */ |
|---|
| 983 | + bool data_path_is_vf; |
|---|
| 984 | + |
|---|
| 985 | + /* Used to temporarily save the config info across hibernation */ |
|---|
| 986 | + struct netvsc_device_info *saved_netvsc_dev_info; |
|---|
| 953 | 987 | }; |
|---|
| 954 | 988 | |
|---|
| 955 | 989 | /* Per channel data */ |
|---|
| .. | .. |
|---|
| 961 | 995 | struct multi_send_data msd; |
|---|
| 962 | 996 | struct multi_recv_comp mrc; |
|---|
| 963 | 997 | atomic_t queue_sends; |
|---|
| 998 | + struct nvsc_rsc rsc; |
|---|
| 999 | + |
|---|
| 1000 | + struct bpf_prog __rcu *bpf_prog; |
|---|
| 1001 | + struct xdp_rxq_info xdp_rxq; |
|---|
| 964 | 1002 | |
|---|
| 965 | 1003 | struct netvsc_stats tx_stats; |
|---|
| 966 | 1004 | struct netvsc_stats rx_stats; |
|---|
| .. | .. |
|---|
| 1143 | 1181 | /* Packet extension field contents associated with a Data message. */ |
|---|
| 1144 | 1182 | struct rndis_per_packet_info { |
|---|
| 1145 | 1183 | u32 size; |
|---|
| 1146 | | - u32 type; |
|---|
| 1184 | + u32 type:31; |
|---|
| 1185 | + u32 internal:1; |
|---|
| 1147 | 1186 | u32 ppi_offset; |
|---|
| 1148 | 1187 | }; |
|---|
| 1149 | 1188 | |
|---|
| .. | .. |
|---|
| 1164 | 1203 | MAX_PER_PKT_INFO |
|---|
| 1165 | 1204 | }; |
|---|
| 1166 | 1205 | |
|---|
| 1206 | +enum rndis_per_pkt_info_interal_type { |
|---|
| 1207 | + RNDIS_PKTINFO_ID = 1, |
|---|
| 1208 | + /* Add more members here */ |
|---|
| 1209 | + |
|---|
| 1210 | + RNDIS_PKTINFO_MAX |
|---|
| 1211 | +}; |
|---|
| 1212 | + |
|---|
| 1213 | +#define RNDIS_PKTINFO_SUBALLOC BIT(0) |
|---|
| 1214 | +#define RNDIS_PKTINFO_1ST_FRAG BIT(1) |
|---|
| 1215 | +#define RNDIS_PKTINFO_LAST_FRAG BIT(2) |
|---|
| 1216 | + |
|---|
| 1217 | +#define RNDIS_PKTINFO_ID_V1 1 |
|---|
| 1218 | + |
|---|
| 1219 | +struct rndis_pktinfo_id { |
|---|
| 1220 | + u8 ver; |
|---|
| 1221 | + u8 flag; |
|---|
| 1222 | + u16 pkt_id; |
|---|
| 1223 | +}; |
|---|
| 1224 | + |
|---|
| 1167 | 1225 | struct ndis_pkt_8021q_info { |
|---|
| 1168 | 1226 | union { |
|---|
| 1169 | 1227 | struct { |
|---|