hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/net/hyperv/hyperv_net.h
....@@ -1,24 +1,12 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 *
34 * 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/>.
165 *
176 * Authors:
187 * Haiyang Zhang <haiyangz@microsoft.com>
198 * Hank Janssen <hjanssen@microsoft.com>
209 * K. Y. Srinivasan <kys@microsoft.com>
21
- *
2210 */
2311
2412 #ifndef _HYPERV_NET_H
....@@ -154,6 +142,8 @@
154142 u32 send_section_size;
155143 u32 recv_section_size;
156144
145
+ struct bpf_prog *bprog;
146
+
157147 u8 rss_key[NETVSC_HASH_KEYLEN];
158148 };
159149
....@@ -186,7 +176,9 @@
186176
187177 /* Interface */
188178 struct rndis_message;
179
+struct ndis_offload_params;
189180 struct netvsc_device;
181
+struct netvsc_channel;
190182 struct net_device_context;
191183
192184 extern u32 netvsc_ring_bytes;
....@@ -199,17 +191,25 @@
199191 struct hv_netvsc_packet *packet,
200192 struct rndis_message *rndis_msg,
201193 struct hv_page_buffer *page_buffer,
202
- struct sk_buff *skb);
194
+ struct sk_buff *skb,
195
+ bool xdp_tx);
203196 void netvsc_linkstatus_callback(struct net_device *net,
204197 struct rndis_message *resp);
205198 int netvsc_recv_callback(struct net_device *net,
206199 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);
211201 void netvsc_channel_cb(void *context);
212202 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);
213213
214214 int rndis_set_subchannel(struct net_device *ndev,
215215 struct netvsc_device *nvdev,
....@@ -223,9 +223,12 @@
223223 struct netvsc_device *nvdev);
224224 int rndis_filter_set_rss_param(struct rndis_device *rdev,
225225 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);
226229 int rndis_filter_receive(struct net_device *ndev,
227230 struct netvsc_device *net_dev,
228
- struct vmbus_channel *channel,
231
+ struct netvsc_channel *nvchan,
229232 void *data, u32 buflen);
230233
231234 int rndis_filter_set_device_mac(struct netvsc_device *ndev,
....@@ -527,6 +530,8 @@
527530 u64 ieee8021q:1;
528531 u64 correlation_id:1;
529532 u64 teaming:1;
533
+ u64 vsubnetid:1;
534
+ u64 rsc:1;
530535 };
531536 };
532537 } __packed;
....@@ -830,7 +835,8 @@
830835
831836 #define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \
832837 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)
834840
835841 #define VRSS_SEND_TAB_SIZE 16 /* must be power of 2 */
836842 #define VRSS_CHANNEL_MAX 64
....@@ -838,6 +844,12 @@
838844
839845 #define RNDIS_MAX_PKT_DEFAULT 8
840846 #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))
841853
842854 struct multi_send_data {
843855 struct sk_buff *skb; /* skb containing the pkt */
....@@ -856,11 +868,25 @@
856868 u32 next; /* next entry for writing */
857869 };
858870
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
+
859884 struct netvsc_stats {
860885 u64 packets;
861886 u64 bytes;
862887 u64 broadcast;
863888 u64 multicast;
889
+ u64 xdp_drop;
864890 struct u64_stats_sync syncp;
865891 };
866892
....@@ -875,6 +901,7 @@
875901 unsigned long rx_no_memory;
876902 unsigned long stop_queue;
877903 unsigned long wake_queue;
904
+ unsigned long vlan_error;
878905 };
879906
880907 struct netvsc_ethtool_pcpu_stats {
....@@ -950,6 +977,13 @@
950977 u32 vf_alloc;
951978 /* Serial number of the VF to team with */
952979 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;
953987 };
954988
955989 /* Per channel data */
....@@ -961,6 +995,10 @@
961995 struct multi_send_data msd;
962996 struct multi_recv_comp mrc;
963997 atomic_t queue_sends;
998
+ struct nvsc_rsc rsc;
999
+
1000
+ struct bpf_prog __rcu *bpf_prog;
1001
+ struct xdp_rxq_info xdp_rxq;
9641002
9651003 struct netvsc_stats tx_stats;
9661004 struct netvsc_stats rx_stats;
....@@ -1143,7 +1181,8 @@
11431181 /* Packet extension field contents associated with a Data message. */
11441182 struct rndis_per_packet_info {
11451183 u32 size;
1146
- u32 type;
1184
+ u32 type:31;
1185
+ u32 internal:1;
11471186 u32 ppi_offset;
11481187 };
11491188
....@@ -1164,6 +1203,25 @@
11641203 MAX_PER_PKT_INFO
11651204 };
11661205
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
+
11671225 struct ndis_pkt_8021q_info {
11681226 union {
11691227 struct {