virtio_net.c (2a1720376adda5ecf8e636fbfb05339c7dad1c55) | virtio_net.c (f0c3192ceee3c16154e70dfb373f66ed86c6fea9) |
---|---|
1/* A network driver using virtio. 2 * 3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 855 unchanged lines hidden (view full) --- 864 865static unsigned int get_mergeable_buf_len(struct receive_queue *rq, 866 struct ewma_pkt_len *avg_pkt_len) 867{ 868 const size_t hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); 869 unsigned int len; 870 871 len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len), | 1/* A network driver using virtio. 2 * 3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 855 unchanged lines hidden (view full) --- 864 865static unsigned int get_mergeable_buf_len(struct receive_queue *rq, 866 struct ewma_pkt_len *avg_pkt_len) 867{ 868 const size_t hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); 869 unsigned int len; 870 871 len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len), |
872 rq->min_buf_len - hdr_len, PAGE_SIZE - hdr_len); | 872 rq->min_buf_len, PAGE_SIZE - hdr_len); |
873 return ALIGN(len, L1_CACHE_BYTES); 874} 875 876static int add_recvbuf_mergeable(struct virtnet_info *vi, 877 struct receive_queue *rq, gfp_t gfp) 878{ 879 struct page_frag *alloc_frag = &rq->alloc_frag; 880 unsigned int headroom = virtnet_get_headroom(vi); --- 1258 unchanged lines hidden (view full) --- 2139static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqueue *vq) 2140{ 2141 const unsigned int hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); 2142 unsigned int rq_size = virtqueue_get_vring_size(vq); 2143 unsigned int packet_len = vi->big_packets ? IP_MAX_MTU : vi->dev->max_mtu; 2144 unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len; 2145 unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size); 2146 | 873 return ALIGN(len, L1_CACHE_BYTES); 874} 875 876static int add_recvbuf_mergeable(struct virtnet_info *vi, 877 struct receive_queue *rq, gfp_t gfp) 878{ 879 struct page_frag *alloc_frag = &rq->alloc_frag; 880 unsigned int headroom = virtnet_get_headroom(vi); --- 1258 unchanged lines hidden (view full) --- 2139static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqueue *vq) 2140{ 2141 const unsigned int hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf); 2142 unsigned int rq_size = virtqueue_get_vring_size(vq); 2143 unsigned int packet_len = vi->big_packets ? IP_MAX_MTU : vi->dev->max_mtu; 2144 unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len; 2145 unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size); 2146 |
2147 return max(min_buf_len, hdr_len); | 2147 return max(max(min_buf_len, hdr_len) - hdr_len, 2148 (unsigned int)GOOD_PACKET_LEN); |
2148} 2149 2150static int virtnet_find_vqs(struct virtnet_info *vi) 2151{ 2152 vq_callback_t **callbacks; 2153 struct virtqueue **vqs; 2154 int ret = -ENOMEM; 2155 int i, total_vqs; --- 588 unchanged lines hidden --- | 2149} 2150 2151static int virtnet_find_vqs(struct virtnet_info *vi) 2152{ 2153 vq_callback_t **callbacks; 2154 struct virtqueue **vqs; 2155 int ret = -ENOMEM; 2156 int i, total_vqs; --- 588 unchanged lines hidden --- |