TSO support.
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 14/22 TSO support.
This includes both TSO-send and TSO-receive support.
--- drivers/xen/netchannel2/chan.c | 3 +- drivers/xen/netchannel2/netchannel2_core.h | 4 +++ drivers/xen/netchannel2/offload.c | 33 ++++++++++++++++++++++++++- drivers/xen/netchannel2/recv_packet.c | 19 ++++++++++++++++ drivers/xen/netchannel2/xmit_packet.c | 8 ++++++ include/xen/interface/io/netchannel2.h | 19 +++++++++++---- 6 files changed, 78 insertions(+), 8 deletions(-)
drivers/xen/netchannel2/chan.c +2 -1
@@ -563,9 +563,10 @@ void nc2_detach_rings(struct netchannel2 *nc) nc->rings.irq =-1 ;/* Disable all offloads */ - nc->net_device->features &= ~(NETIF_F_IP_CSUM |NETIF_F_SG ); + nc->net_device->features &= ~(NETIF_F_IP_CSUM |NETIF_F_SG |NETIF_F_TSO ); nc->allow_tx_csum_offload =0 ; nc->rings.max_fragments_per_tx_packet =1 ; + nc->allow_tso =0 ; }#if defined(CONFIG_XEN_NETDEV2_BACKEND )
drivers/xen/netchannel2/netchannel2_core.h +4 -0
@@ -259,6 +259,10 @@ struct netchannel2 {Whether we actually use TX checksumming is controlled by the net device feature bits. */ uint8_t allow_tx_csum_offload; +/* The remote endpoint allows us to use TSO for TCPv4. As for +checksumming, we only actually use the feature if the net +device says to. */ +uint8_t allow_tso;/* At some point in the past, we tried to tell the other end what our current offload policy is and failed. Try again as soon as possible. */
drivers/xen/netchannel2/offload.c +31 -2
@@ -6,6 +6,7 @@static int nc2_set_tx_csum (struct net_device *nd,u32 val);static int nc2_set_sg (struct net_device *nd,u32 val); +static int nc2_set_tso (struct net_device *nd,u32 val);/* ---------------- Interface to the other domain ----------------------- */ void nc2_handle_set_offload(struct netchannel2 *nc,
@@ -35,6 +36,11 @@ void nc2_handle_set_offload(struct netchannel2 *nc,manually enable it every time. */ nc2_set_sg (nc->net_device, msg.csum); } + +if (msg.tcpv4_segmentation_offload != nc->allow_tso) { + nc->allow_tso = msg.tcpv4_segmentation_offload; +nc2_set_tso (nc->net_device, msg.tcpv4_segmentation_offload); + } }/* Tell the other end what sort of offloads it's allowed to use. */
@@ -46,6 +52,14 @@ void advertise_offloads(struct netchannel2 *nc)if (nc2_can_send_payload_bytes (&nc->rings.prod_ring,sizeof (msg))) { msg.csum = nc->use_rx_csum; +/* We always claim to be able to accept TSO packets, +and don't provide any way of turning it off through +ethtool. We used to use the LRO flag, but that's +not quite right: receiving an LRO packet and +receiving a TSO one are subtly different, due to +the way they get packed into the skbuff +structure. */ + msg.tcpv4_segmentation_offload =1 ;nc2_send_message (&nc->rings.prod_ring,NETCHANNEL2_MSG_SET_OFFLOAD ,0 , &msg,sizeof (msg));
@@ -142,11 +156,26 @@ static int nc2_set_sg(struct net_device *nd, u32 val)return 0 ; } +static int nc2_set_tso (struct net_device *nd,u32 val) +{ +struct netchannel2 *nc =netdev_priv (nd); +/* We only allow ourselves to use TSO if the other end's +allowed us to use sufficiently many fragments per +packet. */ +if (val !=0 && + (!nc->allow_tso || + nc->rings.max_fragments_per_tx_packet <MAX_SKB_FRAGS )) +return -EOPNOTSUPP ; +return ethtool_op_set_tso (nd, val); +} +struct ethtool_ops nc2_ethtool_ops = { .get_tx_csum = ethtool_op_get_tx_csum, .set_tx_csum = nc2_set_tx_csum, .get_rx_csum = nc2_get_rx_csum, .set_rx_csum = nc2_set_rx_csum, - .get_sg = ethtool_op_get_sg, - .set_sg = nc2_set_sg, + .get_sg = ethtool_op_get_sg, + .set_sg = nc2_set_sg, + .get_tso = ethtool_op_get_tso, + .set_tso = nc2_set_tso };
drivers/xen/netchannel2/recv_packet.c +19 -0
@@ -169,6 +169,25 @@ void nc2_handle_packet_msg(struct netchannel2 *nc,break ; } +switch (msg.segmentation_type) { +case NC2_PACKET_SEGMENTATION_TYPE_none: +break ; +case NC2_PACKET_SEGMENTATION_TYPE_tcpv4: +if (msg.mss ==0 ) { +pr_debug ("TSO request with mss == 0?\n" ); + goto err; + } +skb_shinfo (skb)->gso_type = +SKB_GSO_TCPV4 |SKB_GSO_DODGY ; +skb_shinfo (skb)->gso_size = msg.mss; +skb_shinfo (skb)->gso_segs =0 ; +break ; +default : +pr_debug ("Unknown segmentation offload type %d!\n" , + msg.segmentation_type); + goto err; + } +__skb_queue_tail (pending_rx_queue, skb); if (ncrp->pending_rx_hypercalls.nr_pending_gops >=
drivers/xen/netchannel2/xmit_packet.c +8 -0
@@ -104,6 +104,14 @@ static void set_offload_flags(struct sk_buff *skb,if (skb->proto_data_valid) msg->flags |= NC2_PACKET_FLAG_data_validated; + +if (skb_shinfo (skb)->gso_size !=0 ) { + msg->mss =skb_shinfo (skb)->gso_size; + msg->segmentation_type = NC2_PACKET_SEGMENTATION_TYPE_tcpv4; + }else { + msg->mss =0 ; + msg->segmentation_type = NC2_PACKET_SEGMENTATION_TYPE_none; + } }/* Transmit a packet which has previously been prepared with
include/xen/interface/io/netchannel2.h +14 -5
@@ -54,13 +54,13 @@ struct netchannel2_msg_packet {packet message. */ uint8_t type;uint8_t flags; -uint8_t pad0; -uint8_t pad1; +uint8_t segmentation_type; +uint8_t pad;uint16_t prefix_size; -uint16_t pad2; +uint16_t mss;uint16_t csum_start;uint16_t csum_offset; -/* Variable-size array. The number of elements is determined +/* Variable-size array. The number of elements is determined by the size of the message. */ struct netchannel2_fragment frags[0 ]; };
@@ -112,6 +112,9 @@ struct netchannel2_msg_packet {#define NC2_PACKET_TYPE_receiver_copy 1#define NC2_PACKET_TYPE_small 4 +#define NC2_PACKET_SEGMENTATION_TYPE_none 0 +#define NC2_PACKET_SEGMENTATION_TYPE_tcpv4 1 +/* Tell the other end that we're finished with a message it sent us, and it can release the transmit buffers etc. This must be sent in response to receiver_copy and receiver_map packets. It must not be
@@ -140,7 +143,13 @@ struct netchannel2_msg_set_offload {* the other end does not have to perform the calculation. */ uint8_t csum; -uint8_t pad; +/* Segmentation offload. If this is 0, the other end must not +* generate any packet messages with a segmentation type other +* than NC2_PACKET_SEGMENTATION_TYPE_none. If it is 1, the +* other end may also generate packets with a type of +* NC2_PACKET_SEGMENTATION_TYPE_tcpv4. +*/ +uint8_t tcpv4_segmentation_offload;uint16_t reserved; };
Signature · 1 line
1.6.3.1
PATCH 20/22 Posted buffer mode support.
In reply to a message not in the archiveIn this mode, domains are expected to pre-post a number of receive buffers to their peer, and the peer will then copy packets into those buffers when it wants to transmit. This is similar to the way netchannel1 worked.
This isn't particularly useful by itself, because the software-only implementation is slower than the other transmission modes, and is disabled unless you set a #define, but it's necessary for VMQ support.
--- drivers/xen/netchannel2/Makefile | 2 +- drivers/xen/netchannel2/chan.c | 37 ++ drivers/xen/netchannel2/netback2.c | 12 + drivers/xen/netchannel2/netchannel2_core.h | 92 ++++ drivers/xen/netchannel2/netfront2.c | 2 + drivers/xen/netchannel2/posted_buffers.c | 781 ++++++++++++++++++++++++++++ drivers/xen/netchannel2/recv_packet.c | 5 + drivers/xen/netchannel2/xmit_packet.c | 21 + include/xen/interface/io/netchannel2.h | 71 +++ 9 files changed, 1022 insertions(+), 1 deletions(-) create mode 100644 drivers/xen/netchannel2/posted_buffers.c
drivers/xen/netchannel2/Makefile +1 -1
@@ -1,7 +1,7 @@ obj-$(CONFIG_XEN_NETCHANNEL2) += netchannel2.o netchannel2-objs := chan.o netchan2.o rscb.o util.o \ - xmit_packet.o offload.o recv_packet.o poll.o \ + posted_buffers.o xmit_packet.o offload.o recv_packet.o poll.o \ receiver_map.o ifeq ($(CONFIG_XEN_NETDEV2_BACKEND),y)
drivers/xen/netchannel2/chan.c +37 -0
@@ -89,6 +89,15 @@ retry:nc2_handle_set_max_fragments_per_packet (nc, ncrp, &hdr);break ; +case NETCHANNEL2_MSG_POST_BUFFER : +nc2_handle_post_buffer (nc, ncrp, &hdr); +break ; +case NETCHANNEL2_MSG_RETURN_POSTED_BUFFER : +nc2_handle_return_posted_buffer (nc, ncrp, &hdr); +break ; +case NETCHANNEL2_MSG_SET_NR_POSTED_BUFFERS : +nc2_handle_set_nr_posted_buffers (nc, ncrp, &hdr); +break ;case NETCHANNEL2_MSG_BYPASS_FRONTEND :nc2_handle_bypass_frontend (nc, ncrp, &hdr);break ;
@@ -172,8 +181,12 @@ static void flush_rings(struct netchannel2_ring_pair *ncrp)advertise_max_fragments_per_packet (ncrp);if (ncrp == &nc->rings) { +nc2_replenish_rx_buffers (nc); +nc2_return_pending_posted_buffers (nc);if (nc->need_advertise_offloads)advertise_offloads (nc); +if (nc->need_advertise_tx_buffers) +nc2_advertise_tx_buffers (nc);nc2_advertise_bypasses (nc);nc2_crank_aux_ring_state_machine (nc);nc2_autobypass_make_suggestions (nc);
@@ -454,6 +467,13 @@ struct netchannel2 *nc2_new(struct xenbus_device *xd)nc2_release (nc);return NULL ; } +INIT_LIST_HEAD (&nc->rx_buffers); +INIT_LIST_HEAD (&nc->unused_rx_buffers); +INIT_LIST_HEAD (&nc->unposted_rx_buffers); +INIT_LIST_HEAD (&nc->avail_tx_buffers); + nc->nr_avail_tx_buffers =0 ; +INIT_LIST_HEAD (&nc->unused_tx_buffer_slots); +INIT_LIST_HEAD (&nc->pending_tx_buffer_return);if (local_trusted) {if (init_receive_map_mode () <0 ) {
@@ -513,8 +533,13 @@ void nc2_release(struct netchannel2 *nc)nc2_queue_purge (&nc->rings, &nc->pending_skbs); +/* Should have been released when we detached. */ +BUG_ON (nc->rx_buffer_structs); +release_bypasses (nc); +unprepare_tx_buffers (nc); +free_netdev (nc->net_device); }
@@ -604,6 +629,9 @@ int nc2_attach_rings(struct netchannel2 *nc,static void _detach_rings (struct netchannel2_ring_pair *ncrp) { +if (ncrp == &ncrp->interface->rings) +nc2_posted_buffer_rx_forget (ncrp->interface); +spin_lock_bh (&ncrp->lock);/* We need to release all of the pending transmission packets, because they're never going to complete now that we've lost
@@ -795,6 +823,15 @@ static int process_ring(struct napi_struct *napi, skb =__skb_dequeue (&ncrp->pending_tx_queue); }while (skb !=NULL ); +/* If we've transmitted on the main ring then we may +have made use of the hypercall batcher. Flush it. +This must happen before we flush the rings, since +that's when the PACKET messages will be made +visible to the other end. */ +if (ncrp == &nc->rings) +flush_hypercall_batcher (&nc->batcher, + nc2_posted_on_gntcopy_fail); +flush_rings (ncrp);while ((skb =__skb_dequeue (&ncrp->release_on_flush_batcher)))
drivers/xen/netchannel2/netback2.c +12 -0
@@ -11,6 +11,8 @@#include "netchannel2_endpoint.h" #include "netchannel2_uspace.h" +#define NR_TX_BUFS 256 +static atomic_t next_handle;/* A list of all currently-live netback2 interfaces. */ static LIST_HEAD (all_netbacks);
@@ -172,6 +174,11 @@ static int attach_to_frontend(struct netback2 *nd)return 0 ; } +static void nb2_shutdown (struct netchannel2 *nc) +{ +nc2_set_nr_tx_buffers (nc,0 ); +} +static void frontend_changed (struct xenbus_device *xd,enum xenbus_state frontend_state) {
@@ -189,6 +196,8 @@ static void frontend_changed(struct xenbus_device *xd,* detached, and this is pointless but harmless.) */ detach_from_frontend (nb); +nc2_set_nr_tx_buffers (nb->chan,NR_TX_BUFS ); +/* Tell the frontend what sort of rings we're willing to accept. */ xenbus_printf(XBT_NIL, nb->xenbus_device->nodename,
@@ -222,6 +231,7 @@ static void frontend_changed(struct xenbus_device *xd,break ;case XenbusStateClosing: +nb2_shutdown (nb->chan);detach_from_frontend (nb);xenbus_switch_state (xd, XenbusStateClosed);break ;
@@ -257,6 +267,8 @@ static int netback2_uevent(struct xenbus_device *xd,static void netback2_shutdown (struct xenbus_device *xd) { +struct netback2 *nb =xenbus_device_to_nb2 (xd); +nb2_shutdown (nb->chan);xenbus_switch_state (xd, XenbusStateClosing); }
drivers/xen/netchannel2/netchannel2_core.h +92 -0
153 lines not on this page · raw message
drivers/xen/netchannel2/netfront2.c +2 -0
@@ -356,6 +356,8 @@ static void backend_changed(struct xenbus_device *xd,/* Backend has advertised the ring protocol. Allocate the rings, and tell the backend about them. */ +nc2_set_nr_tx_buffers (nf->chan,0 ); + err =0 ;if (!nf->attached) err =allocate_rings (nf, xd->otherend_id);
drivers/xen/netchannel2/posted_buffers.c new file +781 -0
781 lines not on this page · raw message
drivers/xen/netchannel2/recv_packet.c +5 -0
@@ -121,6 +121,11 @@ void nc2_handle_packet_msg(struct netchannel2 *nc, nr_frags, frags_off);queue_finish_packet_message (ncrp, msg.id, msg.flags);break ; +case NC2_PACKET_TYPE_pre_posted: + skb =handle_pre_posted_packet (nc, &msg, hdr, nr_frags, + frags_off); +/* No finish message */ +break ;case NC2_PACKET_TYPE_receiver_map:if (!nc->local_trusted) {/* The remote doesn't trust us, so they
drivers/xen/netchannel2/xmit_packet.c +21 -0
@@ -4,6 +4,11 @@#include <linux/version.h> #include "netchannel2_core.h" +/* You don't normally want to transmit in posted buffers mode, because +grant mode is usually faster, but it's sometimes useful for testing +the VMQ receiver when you don't have VMQ-capable hardware. */ +#define PREFER_POSTED_BUFFERS 0 +/* We limit the number of transmitted packets which can be in flight at any one time, as a somewhat paranoid safety catch. */ #define MAX_TX_PACKETS MAX_PENDING_FINISH_PACKETS
@@ -15,6 +20,16 @@ static enum transmit_policy transmit_policy(struct netchannel2 *nc,return transmit_policy_small; else if (nc->remote_trusted) return transmit_policy_map; + else if (PREFER_POSTED_BUFFERS && + /* We approximate the number of buffers needed by + skb_shinfo(skb)->nr_frags, which isn't entirely + correct, but isn't that far off, either. Getting + it wrong just means we'll delay transmission + waiting for more buffers when we should have gone + ahead with polict grant; not ideal, but hardly a + disaster. */ + nc->nr_avail_tx_buffers > skb_shinfo(skb)->nr_frags) + return transmit_policy_post; else return transmit_policy_grant; }
@@ -76,6 +91,9 @@ enum prepare_xmit_result prepare_xmit_allocate_resources(struct netchannel2 *nc,case transmit_policy_grant: r =prepare_xmit_allocate_grant (&nc->rings, skb,1 );break ; +case transmit_policy_post: + r =prepare_xmit_allocate_post (nc, skb); +break ;case transmit_policy_map: r =prepare_xmit_allocate_grant (&nc->rings, skb,0 );break ;
@@ -177,6 +195,9 @@ int nc2_really_start_xmit(struct netchannel2_ring_pair *ncrp,case transmit_policy_grant:xmit_grant (ncrp, skb,1 , msg);break ; +case transmit_policy_post: +xmit_post (nc, skb, msg); +break ;case transmit_policy_map:xmit_grant (ncrp, skb,0 , msg);break ;
include/xen/interface/io/netchannel2.h +71 -0
95 lines not on this page · raw message
Signature · 1 line
1.6.3.1
PATCH 22/22 Add netchannel2 VMQ support to an old version of the ixgbe driver.
In reply to a message not in the archiveThis is a bit of a mess, and doesn't really want to be applied as-is, but might be useful for testing.
The VMQ patch which I have is against version 1.3.56.5 of the driver, whereas the current 2.6.27 tree has version 2.0.34.3. I don't currently have access to any VMQ-capable hardware, and won't be at Citrix long enough to acquire any, so this patch just rolls the driver back to 1.3.56.5 and adds VMQ support to that.
The original VMQ patch was
My only contribution was to run combinediff, but FWIW that's
--- drivers/net/ixgbe/Makefile | 4 +- drivers/net/ixgbe/ixgbe.h | 220 +- drivers/net/ixgbe/ixgbe_82598.c | 487 ++-- drivers/net/ixgbe/ixgbe_82599.c | 2626 -------------------- drivers/net/ixgbe/ixgbe_api.c | 169 +-- drivers/net/ixgbe/ixgbe_api.h | 57 +- drivers/net/ixgbe/ixgbe_common.c | 622 ++---- drivers/net/ixgbe/ixgbe_common.h | 12 +- drivers/net/ixgbe/ixgbe_dcb.c | 19 +- drivers/net/ixgbe/ixgbe_dcb.h | 28 +- drivers/net/ixgbe/ixgbe_dcb_82598.c | 7 +- drivers/net/ixgbe/ixgbe_dcb_82598.h | 2 +- drivers/net/ixgbe/ixgbe_dcb_82599.c | 508 ---- drivers/net/ixgbe/ixgbe_dcb_82599.h | 125 - drivers/net/ixgbe/ixgbe_dcb_nl.c | 555 +----- drivers/net/ixgbe/ixgbe_ethtool.c | 561 ++---- drivers/net/ixgbe/ixgbe_main.c | 4486 +++++++++++++---------------------- drivers/net/ixgbe/ixgbe_osdep.h | 15 +- drivers/net/ixgbe/ixgbe_param.c | 524 +---- drivers/net/ixgbe/ixgbe_phy.c | 792 +------ drivers/net/ixgbe/ixgbe_phy.h | 27 +- drivers/net/ixgbe/ixgbe_type.h | 938 +-------- drivers/net/ixgbe/kcompat.c | 195 +-- drivers/net/ixgbe/kcompat_ethtool.c | 10 +- drivers/xen/netchannel2/vmq.c | 3 + 25 files changed, 2457 insertions(+), 10535 deletions(-) delete mode 100644 drivers/net/ixgbe/ixgbe_82599.c delete mode 100644 drivers/net/ixgbe/ixgbe_dcb_82599.c delete mode 100644 drivers/net/ixgbe/ixgbe_dcb_82599.h
drivers/net/ixgbe/Makefile +2 -2
@@ -33,8 +33,8 @@ obj-$(CONFIG_IXGBE) += ixgbe.o CFILES = ixgbe_main.c ixgbe_common.c ixgbe_api.c ixgbe_param.c \ - ixgbe_ethtool.c kcompat.c ixgbe_82598.c ixgbe_82599.c \ - ixgbe_dcb.c ixgbe_dcb_nl.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c \ + ixgbe_ethtool.c kcompat.c ixgbe_82598.c \ + ixgbe_dcb.c ixgbe_dcb_nl.c ixgbe_dcb_82598.c \ ixgbe_phy.c ixgbe_sysfs.c ixgbe-objs := $(CFILES:.c=.o)
drivers/net/ixgbe/ixgbe.h +96 -124
427 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_82598.c +241 -246
723 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_82599.c deleted +0 -2626
1,840 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_api.c +4 -165
169 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_api.h +2 -55
57 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_common.c +137 -485
622 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_dcb_82599.c deleted +0 -508
508 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_dcb_82599.h deleted +0 -125
125 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_dcb_nl.c +25 -530
555 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethtool.c +145 -416
561 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_main.c +1597 -2889
4,486 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_param.c +115 -409
524 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_phy.c +26 -766
792 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_type.h +11 -927
938 lines not on this page · raw message
drivers/net/ixgbe/kcompat.c +32 -163
195 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.3.1
Part of the diff is not shown here. View the raw message.