Commit 72151422 authored by Haiyang Zhang's avatar Haiyang Zhang Committed by David S. Miller

hv_netvsc: Define a macro RNDIS_AND_PPI_SIZE

The sum of RNDIS msg and PPI struct sizes is used in multiple places, so we define
a macro for them.
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0d158852
...@@ -958,6 +958,10 @@ struct ndis_tcp_lso_info { ...@@ -958,6 +958,10 @@ struct ndis_tcp_lso_info {
#define NDIS_HASH_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \ #define NDIS_HASH_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
sizeof(u32)) sizeof(u32))
/* Total size of all PPI data */
#define NDIS_ALL_PPI_SIZE (NDIS_VLAN_PPI_SIZE + NDIS_CSUM_PPI_SIZE + \
NDIS_LSO_PPI_SIZE + NDIS_HASH_PPI_SIZE)
/* Format of Information buffer passed in a SetRequest for the OID */ /* Format of Information buffer passed in a SetRequest for the OID */
/* OID_GEN_RNDIS_CONFIG_PARAMETER. */ /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
struct rndis_config_parameter_info { struct rndis_config_parameter_info {
...@@ -1170,6 +1174,8 @@ struct rndis_message { ...@@ -1170,6 +1174,8 @@ struct rndis_message {
#define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \ #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
sizeof(union rndis_message_container)) sizeof(union rndis_message_container))
#define RNDIS_AND_PPI_SIZE (sizeof(struct rndis_message) + NDIS_ALL_PPI_SIZE)
#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
......
...@@ -401,10 +401,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -401,10 +401,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
pkt_sz = sizeof(struct hv_netvsc_packet) + pkt_sz = sizeof(struct hv_netvsc_packet) + RNDIS_AND_PPI_SIZE;
sizeof(struct rndis_message) +
NDIS_VLAN_PPI_SIZE + NDIS_CSUM_PPI_SIZE +
NDIS_LSO_PPI_SIZE + NDIS_HASH_PPI_SIZE;
if (head_room < pkt_sz) { if (head_room < pkt_sz) {
packet = kmalloc(pkt_sz, GFP_ATOMIC); packet = kmalloc(pkt_sz, GFP_ATOMIC);
...@@ -436,11 +433,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) ...@@ -436,11 +433,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
packet->rndis_msg = (struct rndis_message *)((unsigned long)packet + packet->rndis_msg = (struct rndis_message *)((unsigned long)packet +
sizeof(struct hv_netvsc_packet)); sizeof(struct hv_netvsc_packet));
memset(packet->rndis_msg, 0, sizeof(struct rndis_message) + memset(packet->rndis_msg, 0, RNDIS_AND_PPI_SIZE);
NDIS_VLAN_PPI_SIZE +
NDIS_CSUM_PPI_SIZE +
NDIS_LSO_PPI_SIZE +
NDIS_HASH_PPI_SIZE);
/* Set the completion routine */ /* Set the completion routine */
packet->send_completion = netvsc_xmit_completion; packet->send_completion = netvsc_xmit_completion;
...@@ -872,9 +865,7 @@ static int netvsc_probe(struct hv_device *dev, ...@@ -872,9 +865,7 @@ static int netvsc_probe(struct hv_device *dev,
return -ENOMEM; return -ENOMEM;
max_needed_headroom = sizeof(struct hv_netvsc_packet) + max_needed_headroom = sizeof(struct hv_netvsc_packet) +
sizeof(struct rndis_message) + RNDIS_AND_PPI_SIZE;
NDIS_VLAN_PPI_SIZE + NDIS_CSUM_PPI_SIZE +
NDIS_LSO_PPI_SIZE + NDIS_HASH_PPI_SIZE;
netif_carrier_off(net); netif_carrier_off(net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment