diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2015-02-13 01:43:44 -0500 |
|---|---|---|
| committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-02-13 01:45:54 -0500 |
| commit | ed9ecb0415b97b5f9f91f146e1977bb372c74c6d (patch) | |
| tree | f4208700a00b17b8455d2bf4f4c8e5459f014ece | |
| parent | 1e1c17a7a2e5c585926eefffbea8a61d7a03a247 (diff) | |
virtio: Don't expose legacy net features when VIRTIO_NET_NO_LEGACY defined.
In particular, the virtio header always has the u16 num_buffers field.
We define a new 'struct virtio_net_hdr_v1' for this (rather than
simply calling it 'struct virtio_net_hdr', to avoid nasty type errors
if some parts of a project define VIRTIO_NET_NO_LEGACY and some don't.
Transitional devices (which can't define VIRTIO_NET_NO_LEGACY) will
have to keep using struct virtio_net_hdr_mrg_rxbuf, which has the same
byte layout as struct virtio_net_hdr_v1.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
| -rw-r--r-- | include/uapi/linux/virtio_net.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index b5f1677b291c..4a9b58113d6e 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h | |||
| @@ -35,7 +35,6 @@ | |||
| 35 | #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ | 35 | #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ |
| 36 | #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ | 36 | #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ |
| 37 | #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ | 37 | #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ |
| 38 | #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ | ||
| 39 | #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ | 38 | #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ |
| 40 | #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ | 39 | #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ |
| 41 | #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ | 40 | #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ |
| @@ -56,6 +55,10 @@ | |||
| 56 | * Steering */ | 55 | * Steering */ |
| 57 | #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ | 56 | #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ |
| 58 | 57 | ||
| 58 | #ifndef VIRTIO_NET_NO_LEGACY | ||
| 59 | #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ | ||
| 60 | #endif /* VIRTIO_NET_NO_LEGACY */ | ||
| 61 | |||
| 59 | #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ | 62 | #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ |
| 60 | #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ | 63 | #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ |
| 61 | 64 | ||
| @@ -71,8 +74,9 @@ struct virtio_net_config { | |||
| 71 | __u16 max_virtqueue_pairs; | 74 | __u16 max_virtqueue_pairs; |
| 72 | } __attribute__((packed)); | 75 | } __attribute__((packed)); |
| 73 | 76 | ||
| 77 | #ifndef VIRTIO_NET_NO_LEGACY | ||
| 74 | /* This header comes first in the scatter-gather list. | 78 | /* This header comes first in the scatter-gather list. |
| 75 | * If VIRTIO_F_ANY_LAYOUT is not negotiated, it must | 79 | * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must |
| 76 | * be the first element of the scatter-gather list. If you don't | 80 | * be the first element of the scatter-gather list. If you don't |
| 77 | * specify GSO or CSUM features, you can simply ignore the header. */ | 81 | * specify GSO or CSUM features, you can simply ignore the header. */ |
| 78 | struct virtio_net_hdr { | 82 | struct virtio_net_hdr { |
| @@ -97,6 +101,30 @@ struct virtio_net_hdr_mrg_rxbuf { | |||
| 97 | struct virtio_net_hdr hdr; | 101 | struct virtio_net_hdr hdr; |
| 98 | __virtio16 num_buffers; /* Number of merged rx buffers */ | 102 | __virtio16 num_buffers; /* Number of merged rx buffers */ |
| 99 | }; | 103 | }; |
| 104 | #else /* ... VIRTIO_NET_NO_LEGACY */ | ||
| 105 | /* | ||
| 106 | * This header comes first in the scatter-gather list. If you don't | ||
| 107 | * specify GSO or CSUM features, you can simply ignore the header. | ||
| 108 | * | ||
| 109 | * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf. | ||
| 110 | */ | ||
| 111 | struct virtio_net_hdr_v1 { | ||
| 112 | #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ | ||
| 113 | #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ | ||
| 114 | __u8 flags; | ||
| 115 | #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ | ||
| 116 | #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ | ||
| 117 | #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ | ||
| 118 | #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ | ||
| 119 | #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ | ||
| 120 | __u8 gso_type; | ||
| 121 | __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ | ||
| 122 | __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ | ||
| 123 | __virtio16 csum_start; /* Position to start checksumming from */ | ||
| 124 | __virtio16 csum_offset; /* Offset after that to place checksum */ | ||
| 125 | __virtio16 num_buffers; /* Number of merged rx buffers */ | ||
| 126 | }; | ||
| 127 | #endif /* ...VIRTIO_NET_NO_LEGACY */ | ||
| 100 | 128 | ||
| 101 | /* | 129 | /* |
| 102 | * Control virtqueue data structures | 130 | * Control virtqueue data structures |
