WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Xen

xen-devel

[Top] [All Lists]

[Xen-devel] [3/4] [NET] back: Make extra info slot more generic

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: [Xen-devel] [3/4] [NET] back: Make extra info slot more generic
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: 2006年6月30日 12:42:33 +1000
Cc: Xen Development Mailing List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: 2006年6月29日 19:43:55 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060629230834.GA26561@xxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <d963f536d9918d951418dcf1b935d1d9@xxxxxxxxxxxx> <20060629002020.GA16348@xxxxxxxxxxxxxxxxxxx> <390960d535dacfea77754357cf9cc55e@xxxxxxxxxxxx> <20060629094045.GA20816@xxxxxxxxxxxxxxxxxxx> <bc12b2d3847b6c6d03668954b8f3d25c@xxxxxxxxxxxx> <20060629124614.GA21911@xxxxxxxxxxxxxxxxxxx> <e9220840c1d7241f72f58c1771c74d40@xxxxxxxxxxxx> <20060629132608.GA22343@xxxxxxxxxxxxxxxxxxx> <bd7d2589ed6bff8876dbfe4790244fb0@xxxxxxxxxxxx> <20060629230834.GA26561@xxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
Hi:
[NET] back: Make extra info slot more generic
Based on suggestions by Keir Fraser, this patch makes the extra slot more
generic by allowing it to be chained and giving each slot a type field.
This makes it easier to add new extra slots such as checksum offset.
I've also added GSO type constants specific for Xen. For now the conversion
function between them and Linux is a noop. When and if they do diverge we
can modify them accordingly.
This patch also gets rid of gso_segs which is now always recomputed for
SKB_GSO_DODGY packets.
Last but not least netback now actually sets SKB_GSO_DODGY.
Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff -r 752477acd893 -r bd0c0b635dc1 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Fri Jun 30 
12:13:27 2006 +1000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Fri Jun 30 
12:36:57 2006 +1000
@@ -663,6 +663,35 @@ static void netbk_fill_frags(struct sk_b
 }
 }
 
+int netbk_get_txtras(netif_t *netif, struct netif_tx_extra *txtras,
+ int work_to_do)
+{
+ struct netif_tx_extra *txtra;
+ int i = netif->tx.req_cons;
+
+ do {
+
+ if (unlikely(work_to_do-- <= 0)) {
+ DPRINTK("Missing extra info\n");
+ return -EBADR;
+ }
+
+ txtra = (struct netif_tx_extra *)RING_GET_REQUEST(&netif->tx,
+ i);
+ if (unlikely(!txtra->type ||
+ txtra->type >= XEN_NETIF_TXTRA_TYPE_MAX)) {
+ netif->tx.req_cons = ++i;
+ DPRINTK("Invalid extra type: %d\n", txtra->type);
+ return -EINVAL;
+ }
+
+ memcpy(txtras + txtra->type - 1, txtra, sizeof(*txtra));
+ netif->tx.req_cons = ++i;
+ } while (txtra->flags & XEN_NETIF_TXTRA_MORE);
+
+ return work_to_do;
+}
+
 /* Called after netfront has transmitted */
 static void net_tx_action(unsigned long unused)
 {
@@ -670,7 +699,8 @@ static void net_tx_action(unsigned long 
 struct sk_buff *skb;
 netif_t *netif;
 netif_tx_request_t txreq;
- struct netif_tx_extra txtra;
+ struct netif_tx_extra txtras[XEN_NETIF_TXTRA_TYPE_MAX - 1];
+ struct netif_tx_extra *gso;
 u16 pending_idx;
 RING_IDX i;
 gnttab_map_grant_ref_t *mop;
@@ -732,16 +762,15 @@ static void net_tx_action(unsigned long 
 work_to_do--;
 netif->tx.req_cons = ++i;
 
+ memset(txtras, 0, sizeof(txtras));
 if (txreq.flags & NETTXF_extra_info) {
- if (work_to_do-- <= 0) {
- DPRINTK("Missing extra info\n");
- netbk_tx_err(netif, &txreq, i);
+ work_to_do = netbk_get_txtras(netif, txtras,
+ work_to_do);
+ if (unlikely(work_to_do < 0)) {
+ netbk_tx_err(netif, &txreq, 0);
 continue;
 }
-
- memcpy(&txtra, RING_GET_REQUEST(&netif->tx, i),
- sizeof(txtra));
- netif->tx.req_cons = ++i;
+ i = netif->tx.req_cons;
 }
 
 ret = netbk_count_requests(netif, &txreq, work_to_do);
@@ -772,6 +801,32 @@ static void net_tx_action(unsigned long 
 continue;
 }
 
+ gso = NULL;
+ if (txtras[XEN_NETIF_TXTRA_TYPE_GSO - 1].type) {
+ /* In future this will be retrieved from Linux. */
+ unsigned int allowed_types = SKB_GSO_TCPV4 |
+ SKB_GSO_DODGY;
+ unsigned type;
+
+ gso = &txtras[XEN_NETIF_TXTRA_TYPE_GSO - 1];
+ if (!gso->gso.size) {
+ DPRINTK("GSO size must not be zero\n");
+ netbk_tx_err(netif, &txreq, i);
+ continue; 
+ }
+
+ type = xen_gso_type_xen2linux(gso->gso.type);
+ if (!type || (type & allowed_types) != type) {
+ DPRINTK("Bogus GSO type: 0x%x\n",
+ gso->gso.type);
+ netbk_tx_err(netif, &txreq, i);
+ continue; 
+ }
+
+ /* Whoever gets this needs to verify the header. */
+ gso->gso.type = type | SKB_GSO_DODGY;
+ }
+
 pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
 
 data_len = (txreq.size > PKT_PROT_LEN &&
@@ -788,10 +843,9 @@ static void net_tx_action(unsigned long 
 /* Packets passed to netif_rx() must have some headroom. */
 skb_reserve(skb, 16);
 
- if (txreq.flags & NETTXF_gso) {
- skb_shinfo(skb)->gso_size = txtra.u.gso.size;
- skb_shinfo(skb)->gso_segs = txtra.u.gso.segs;
- skb_shinfo(skb)->gso_type = txtra.u.gso.type;
+ if (gso) {
+ skb_shinfo(skb)->gso_size = gso->gso.size;
+ skb_shinfo(skb)->gso_type = gso->gso.type;
 }
 
 gnttab_set_map_op(mop, MMAP_VADDR(pending_idx),
diff -r 752477acd893 -r bd0c0b635dc1 xen/include/public/io/netif.h
--- a/xen/include/public/io/netif.h Fri Jun 30 12:13:27 2006 +1000
+++ b/xen/include/public/io/netif.h Fri Jun 30 12:36:57 2006 +1000
@@ -41,12 +41,28 @@
 #define _NETTXF_more_data (2)
 #define NETTXF_more_data (1U<<_NETTXF_more_data)
 
-/* Packet has GSO fields in the following descriptor (netif_tx_extra.u.gso). */
-#define _NETTXF_gso (3)
-#define NETTXF_gso (1U<<_NETTXF_gso)
+/* Packet to be folloed by extra descritptor. */
+#define _NETTXF_extra_info (3)
+#define NETTXF_extra_info (1U<<_NETTXF_extra_info)
 
-/* This descriptor is followed by an extra-info descriptor (netif_tx_extra). */
-#define NETTXF_extra_info (NETTXF_gso)
+enum {
+ XEN_NETIF_TXTRA_TYPE_GSO = 1,
+ XEN_NETIF_TXTRA_TYPE_MAX,
+};
+
+enum {
+ XEN_NETIF_TXTRA_MORE = 1 << 0,
+};
+
+enum {
+ /* TCP over IPv4. */
+ XEN_GSO_TCPV4 = 1 << 0,
+ /* UDP over IPv4. */
+ XEN_GSO_UDPV4 = 1 << 1,
+
+ /* Packet header must be verified. */
+ XEN_GSO_DODGY = 1 << 2,
+};
 
 struct netif_tx_request {
 grant_ref_t gref; /* Reference to buffer page */
@@ -57,16 +73,29 @@ struct netif_tx_request {
 };
 typedef struct netif_tx_request netif_tx_request_t;
 
-/* This structure needs to fit within netif_tx_request for compatibility. */
+/*
+ * This structure needs to fit within both netif_tx_request and
+ * netif_rx_response for compatibility.
+ */
 struct netif_tx_extra {
+ /* Type of extra info. */
+ uint8_t type;
+ /* Flags for this info. */
+ uint8_t flags;
+
 union {
- /* NETTXF_gso: Generic Segmentation Offload. */
- struct netif_tx_gso {
- uint16_t size; /* GSO MSS. */
- uint16_t segs; /* GSO segment count. */
- uint16_t type; /* GSO type. */
- } gso;
- } u;
+ /*
+ * Maximum payload size of each segment. For example, for TCP this is
+ * just the path MSS.
+ */
+ uint16_t size;
+
+ /*
+ * GSO type. This determines the protocol of the packet and any extra
+ * features required to segment the packet properly.
+ */
+ uint16_t type;
+ } gso;
 };
 
 struct netif_tx_response {
@@ -110,6 +139,17 @@ DEFINE_RING_TYPES(netif_rx, struct netif
 /* No response: used for auxiliary requests (e.g., netif_tx_extra). */
 #define NETIF_RSP_NULL 1
 
+/* For now the GSO types are identical. */
+static inline int xen_gso_type_linux2xen(int type)
+{
+ return type;
+}
+
+static inline int xen_gso_type_xen2linux(int type)
+{
+ return type;
+}
+
 #endif
 
 /*
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
Previous by Date: [Xen-devel] [2/4] [NET]: Add net-tso.patch , Herbert Xu
Next by Date: [Xen-devel] [4/4] [NET] front: Transmit TSO packets if supported , Herbert Xu
Previous by Thread: [Xen-devel] [2/4] [NET]: Add net-tso.patch , Herbert Xu
Next by Thread: [Xen-devel] [4/4] [NET] front: Transmit TSO packets if supported , Herbert Xu
Indexes: [Date] [Thread] [Top] [All Lists]

Copyright ©, Citrix Systems Inc. All rights reserved. Legal and Privacy
Citrix This site is hosted by Citrix

AltStyle によって変換されたページ (->オリジナル) /