Hi,

Kernel version 2.6.15 onwards provides UDP Fragmentation Offload (UFO)
This patch to ethtool provides UFO (UDP Fragmentation Offload) on/off support 
using -K option similar to feature TSO.

To find out whether UFO is enabled or not use 
#ethtool -k eth3
Offload parameters for eth3:
rx-checksumming: on
tx-checksumming: on
scatter-gather: on
tcp segmentation offload: on
udp fragmentation offload: on
#

To turn off UFO use following command.
#ethtool -K eth3 ufo off

To turn off UFO use following command.
#ethtool -K eth3 ufo on


Please review the patch.

Signed-off-by: Ananda Raju <[EMAIL PROTECTED]>
---
diff -uNr ethtool-3/ethtool-copy.h ethtool-3_ufo/ethtool-copy.h
--- ethtool-3/ethtool-copy.h    2005-10-14 08:34:20.000000000 -0700
+++ ethtool-3_ufo/ethtool-copy.h        2005-10-14 08:33:41.000000000 -0700
@@ -283,6 +283,8 @@
 #define ETHTOOL_GSTATS         0x0000001d /* get NIC-specific statistics */
 #define ETHTOOL_GTSO           0x0000001e /* Get TSO enable (ethtool_value) */
 #define ETHTOOL_STSO           0x0000001f /* Set TSO enable (ethtool_value) */
+#define ETHTOOL_GUFO           0x00000021 /* Get UFO enable (ethtool_value) */
+#define ETHTOOL_SUFO           0x00000022 /* Set UFO enable (ethtool_value) */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET         ETHTOOL_GSET
diff -uNr ethtool-3/ethtool.c ethtool-3_ufo/ethtool.c
--- ethtool-3/ethtool.c 2005-10-14 08:34:15.000000000 -0700
+++ ethtool-3_ufo/ethtool.c     2005-10-14 08:33:26.000000000 -0700
@@ -119,6 +119,7 @@
  *             [ tx on|off ] \
  *             [ sg on|off ] \
  *             [ tso on|off ]
+ *             [ ufo on|off ]
  *     ethtool -r DEVNAME
  *     ethtool -p DEVNAME [ %d ]
  *     ethtool -t DEVNAME [ online|offline ]
@@ -191,6 +192,7 @@
                "               [ tx on|off ] \\\n"
                "               [ sg on|off ] \\\n"
                "               [ tso on|off ]\n"
+               "               [ ufo on|off ]\n"
                "       ethtool -r DEVNAME\n"
                "       ethtool -p DEVNAME [ %%d ]\n"
                "       ethtool -t DEVNAME [online|(offline)]\n"
@@ -236,6 +238,7 @@
 static int off_csum_tx_wanted = -1;
 static int off_sg_wanted = -1;
 static int off_tso_wanted = -1;
+static int off_ufo_wanted = -1;
 
 static struct ethtool_pauseparam epause;
 static int gpause_changed = 0;
@@ -339,6 +342,7 @@
        { "tx", CMDL_BOOL, &off_csum_tx_wanted, NULL },
        { "sg", CMDL_BOOL, &off_sg_wanted, NULL },
        { "tso", CMDL_BOOL, &off_tso_wanted, NULL },
+       { "ufo", CMDL_BOOL, &off_ufo_wanted, NULL },
 };
 
 static struct cmdline_info cmdline_pause[] = {
@@ -1184,17 +1188,19 @@
        return 0;
 }
 
-static int dump_offload (int rx, int tx, int sg, int tso)
+static int dump_offload (int rx, int tx, int sg, int tso, int ufo)
 {
        fprintf(stdout,
                "rx-checksumming: %s\n"
                "tx-checksumming: %s\n"
                "scatter-gather: %s\n"
-               "tcp segmentation offload: %s\n",
+               "tcp segmentation offload: %s\n"
+               "udp fragmentation offload: %s\n",
                rx ? "on" : "off",
                tx ? "on" : "off",
                sg ? "on" : "off",
-               tso ? "on" : "off");
+               tso ? "on" : "off",
+               ufo ? "on" : "off");
 
        return 0;
 }
@@ -1458,7 +1464,7 @@
 static int do_goffload(int fd, struct ifreq *ifr)
 {
        struct ethtool_value eval;
-       int err, allfail = 1, rx = 0, tx = 0, sg = 0, tso = 0;
+       int err, allfail = 1, rx = 0, tx = 0, sg = 0, tso = 0, ufo = 0;
 
        fprintf(stdout, "Offload parameters for %s:\n", devname);
 
@@ -1502,12 +1508,22 @@
                allfail = 0;
        }
 
+       eval.cmd = ETHTOOL_GUFO;
+       ifr->ifr_data = (caddr_t)&eval;
+       err = ioctl(fd, SIOCETHTOOL, ifr);
+       if (err)
+               perror("Cannot get device udp large send offload settings");
+       else {
+               ufo = eval.data;
+               allfail = 0;
+       }
+
        if (allfail) {
                fprintf(stdout, "no offload info available\n");
                return 83;
        }
 
-       return dump_offload(rx, tx, sg, tso);
+       return dump_offload(rx, tx, sg, tso, ufo);
 }
 
 static int do_soffload(int fd, struct ifreq *ifr)
@@ -1562,6 +1578,17 @@
                        return 88;
                }
        }
+       if (off_ufo_wanted >= 0) {
+               changed = 1;
+               eval.cmd = ETHTOOL_SUFO;
+               eval.data = (off_ufo_wanted == 1);
+               ifr->ifr_data = (caddr_t)&eval;
+               err = ioctl(fd, SIOCETHTOOL, ifr);
+               if (err) {
+                       perror("Cannot set device udp large send offload 
settings");
+                       return 89;
+               }
+       }
        if (!changed) {
                fprintf(stdout, "no offload settings changed\n");
        }

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to