[Qemu-devel] qemu/hw rtl8139.c

2008-03-13 Thread Aurelien Jarno
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Aurelien Jarno 08/03/13 19:17:40

Modified files:
hw : rtl8139.c 

Log message:
rtl8139: fix endianness on big endian targets

On big endian targets with mmio accesses, the values are not always
swapped, depending on the accessed register. The Linux 8139too module
was able to cope with that, but not the 8139cp one.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.18&r2=1.19




[Qemu-devel] qemu/hw rtl8139.c

2007-11-09 Thread Thiemo Seufer
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Thiemo Seufer  07/11/09 18:17:50

Modified files:
hw : rtl8139.c 

Log message:
Fix typo, spotted by Samuel Thibault.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.13&r2=1.14




[Qemu-devel] qemu/hw rtl8139.c

2007-08-01 Thread Thiemo Seufer
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Thiemo Seufer  07/08/01 13:10:29

Modified files:
hw : rtl8139.c 

Log message:
Fix rtl8139 checksum calculation, by Tim Deegan.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.10&r2=1.11




[Qemu-devel] qemu/hw rtl8139.c

2007-04-06 Thread Paul Brook
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Paul Brook  07/04/07 01:41:50

Modified files:
hw : rtl8139.c 

Log message:
Remove dead code.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.7&r2=1.8




[Qemu-devel] qemu/hw rtl8139.c

2007-03-19 Thread Thiemo Seufer
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Thiemo Seufer  07/03/19 18:20:28

Modified files:
hw : rtl8139.c 

Log message:
Fix big endian host operation, by Ben Taylor and Igor Kovalenko.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.6&r2=1.7


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[Qemu-devel] qemu/hw rtl8139.c

2006-07-10 Thread Fabrice Bellard
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Fabrice Bellard06/07/10 21:38:17

Modified files:
hw : rtl8139.c 

Log message:
fixed for TCP segmentation offloading - removed dependency on slirp.h 
(Igor Kovalenko)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.3&r2=1.4


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


Re: [Qemu-devel] qemu/hw rtl8139.c

2006-07-10 Thread Igor Kovalenko
On 7/9/06, Igor Kovalenko wrote:
Hi!This updated patch against current CVS implements TCP segmentation offloading for RTL8139 in C+ mode.I fixed a couple of problems in implementation (wrong sequence number calculation), and now TCP performance seem to be normal.
Dependency on slirp.h header is now gone.Again tested with linux (ethtool -K eth0 tx on sg on tso on); please apply.It turned out that a couple of variable types were left dependent on 
slirp.hand transmit/receive pointers were not reset in right places (required for freebsd re driver)This is an incremental update to fix these problems.


--- hw/rtl8139-20060709-with-working-tso-2.c	2006-07-09 12:41:47.0 +0400
+++ hw/rtl8139.c	2006-07-11 01:15:27.0 +0400
@@ -40,6 +40,7 @@
  *  2006-Jul-09  Igor Kovalenko :   Fixed TCP header length calculation while processing
  *  segmentation offloading
  *  Removed slirp.h dependency
+ *  Added rx/tx buffer reset when enabling rx/tx operation
  */
 
 #include "vl.h"
@@ -1368,10 +1369,14 @@
 if (val & CmdRxEnb)
 {
 DEBUG_PRINT(("RTL8139: ChipCmd enable receiver\n"));
+
+s->currCPlusRxDesc = 0;
 }
 if (val & CmdTxEnb)
 {
 DEBUG_PRINT(("RTL8139: ChipCmd enable transmitter\n"));
+
+s->currCPlusTxDesc = 0;
 }
 
 /* mask unwriteable bits */
@@ -2078,8 +2083,8 @@
 /* ip packet header */
 ip_header *ip = 0;
 int hlen = 0;
-u_int8_t  ip_protocol = 0;
-u_int16_t ip_data_len = 0;
+uint8_t  ip_protocol = 0;
+uint16_t ip_data_len = 0;
 
 uint8_t *eth_payload_data = 0;
 size_t   eth_payload_len  = 0;
@@ -2450,8 +2455,6 @@
 DEBUG_PRINT(("RTL8139: TxAddr write offset=0x%x val=0x%08x\n", txAddrOffset, val));
 
 s->TxAddr[txAddrOffset/4] = le32_to_cpu(val);
-
-s->currCPlusTxDesc = 0;
 }
 
 static uint32_t rtl8139_TxAddr_read(RTL8139State *s, uint32_t txAddrOffset)
___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


Re: [Qemu-devel] qemu/hw rtl8139.c

2006-07-09 Thread Igor Kovalenko
Hi!This updated patch against current CVS implements TCP segmentation offloading for RTL8139 in C+ mode.I fixed a couple of problems in implementation (wrong sequence number calculation), and now TCP performance seem to be normal.
Dependency on slirp.h header is now gone.Again tested with linux (ethtool -K eth0 tx on sg on tso on); please apply.--Kind Regards,Igor V. Kovalenko
Index: hw/rtl8139.c
===
RCS file: /cvsroot/qemu/qemu/hw/rtl8139.c,v
retrieving revision 1.3
diff -u -r1.3 rtl8139.c
--- hw/rtl8139.c	4 Jul 2006 10:08:36 -	1.3
+++ hw/rtl8139.c	9 Jul 2006 09:14:00 -
@@ -33,13 +33,17 @@
  *  Implemented PCI timer interrupt (disabled by default)
  *  Implemented Tally Counters, increased VM load/save version
  *  Implemented IP/TCP/UDP checksum task offloading
+ *
+ *  2006-Jul-04  Igor Kovalenko :   Implemented TCP segmentation offloading
+ *  Fixed MTU=1500 for produced ethernet frames
+ *
+ *  2006-Jul-09  Igor Kovalenko :   Fixed TCP header length calculation while processing
+ *  segmentation offloading
+ *  Removed slirp.h dependency
  */
 
 #include "vl.h"
 
-/* XXX: such dependency must be suppressed */
-#include 
-
 /* debug RTL8139 card */
 //#define DEBUG_RTL8139 1
 
@@ -1732,6 +1736,25 @@
 return ret;
 }
 
+static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size, int do_interrupt)
+{
+if (!size)
+{
+DEBUG_PRINT(("RTL8139: +++ empty ethernet frame\n"));
+return;
+}
+
+if (TxLoopBack == (s->TxConfig & TxLoopBack))
+{
+DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
+rtl8139_do_receive(s, buf, size, do_interrupt);
+}
+else
+{
+qemu_send_packet(s->vc, buf, size);
+}
+}
+
 static int rtl8139_transmit_one(RTL8139State *s, int descriptor)
 {
 if (!rtl8139_transmitter_enabled(s))
@@ -1762,15 +1785,7 @@
 s->TxStatus[descriptor] |= TxHostOwns;
 s->TxStatus[descriptor] |= TxStatOK;
 
-if (TxLoopBack == (s->TxConfig & TxLoopBack))
-{
-DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
-rtl8139_do_receive(s, txbuffer, txsize, 0);
-}
-else
-{
-qemu_send_packet(s->vc, txbuffer, txsize);
-}
+rtl8139_transfer_frame(s, txbuffer, txsize, 0);
 
 DEBUG_PRINT(("RTL8139: +++ transmitted %d bytes from descriptor %d\n", txsize, descriptor));
 
@@ -1781,6 +1796,93 @@
 return 1;
 }
 
+/* structures and macros for task offloading */
+typedef struct ip_header
+{
+uint8_t  ip_ver_len;/* version and header length */
+uint8_t  ip_tos;/* type of service */
+uint16_t ip_len;/* total length */
+uint16_t ip_id; /* identification */
+uint16_t ip_off;/* fragment offset field */
+uint8_t  ip_ttl;/* time to live */
+uint8_t  ip_p;  /* protocol */
+uint16_t ip_sum;/* checksum */
+uint32_t ip_src,ip_dst; /* source and dest address */
+} ip_header;
+
+#define IP_HEADER_VERSION_4 4
+#define IP_HEADER_VERSION(ip) ((ip->ip_ver_len >> 4)&0xf)
+#define IP_HEADER_LENGTH(ip) (((ip->ip_ver_len)&0xf) << 2)
+
+typedef struct tcp_header
+{
+uint16_t th_sport;		/* source port */
+uint16_t th_dport;		/* destination port */
+uint32_t th_seq;			/* sequence number */
+uint32_t th_ack;			/* acknowledgement number */
+uint16_t th_offset_flags; /* data offset, reserved 6 bits, TCP protocol flags */
+uint16_t th_win;			/* window */
+uint16_t th_sum;			/* checksum */
+uint16_t th_urp;			/* urgent pointer */
+} tcp_header;
+
+typedef struct udp_header
+{
+uint16_t uh_sport; /* source port */
+uint16_t uh_dport; /* destination port */
+uint16_t uh_ulen;  /* udp length */
+uint16_t uh_sum;   /* udp checksum */
+} udp_header;
+
+typedef struct ip_pseudo_header
+{
+uint32_t ip_src;
+uint32_t ip_dst;
+uint8_t  zeros;
+uint8_t  ip_proto;
+uint16_t ip_payload;
+} ip_pseudo_header;
+
+#define IP_PROTO_TCP 6
+#define IP_PROTO_UDP 17
+
+#define TCP_HEADER_DATA_OFFSET(tcp) (((be16_to_cpu(tcp->th_offset_flags) >> 12)&0xf) << 2)
+#define TCP_FLAGS_ONLY(flags) ((flags)&0x3f)
+#define TCP_HEADER_FLAGS(tcp) TCP_FLAGS_ONLY(be16_to_cpu(tcp->th_offset_flags))
+
+#define TCP_HEADER_CLEAR_FLAGS(tcp, off) ((tcp)->th_offset_flags &= cpu_to_be16(~TCP_FLAGS_ONLY(off)))
+
+#define TCP_FLAG_FIN  0x01
+#define TCP_FLAG_PUSH 0x08
+
+/* produces ones' complement sum of data */
+static uint16_t ones_complement_sum(uint8_t *data, size_t len)
+{
+uint32_t result = 0;
+
+for (; len > 1; data+=2, len-=2)
+{
+result += *(uint16_t*)data;
+}
+
+/* add the remainder byte */
+if (len)
+{
+uint8_t odd[2] = {*data, 0};
+result += *(uint16_

Re: [Qemu-devel] qemu/hw rtl8139.c

2006-07-04 Thread Igor Kovalenko
Hi!Here is the remaining part of task offloading features of rtl8139 emulation - the TCP segmentation offloading.Tested with linux (ethtool -K eth0 tx on sg on tso on).Please apply.I'll try to provide slirp separation later.
--Kind Regards,Igor V. Kovalenko
Index: hw/rtl8139.c
===
RCS file: /cvsroot/qemu/qemu/hw/rtl8139.c,v
retrieving revision 1.3
diff -u -r1.3 rtl8139.c
--- hw/rtl8139.c	4 Jul 2006 10:08:36 -	1.3
+++ hw/rtl8139.c	4 Jul 2006 21:38:55 -
@@ -33,6 +33,9 @@
  *  Implemented PCI timer interrupt (disabled by default)
  *  Implemented Tally Counters, increased VM load/save version
  *  Implemented IP/TCP/UDP checksum task offloading
+ *
+ *  2006-Jul-04  Igor Kovalenko :   Implemented TCP segmentation offloading
+ *  Fixed MTU=1500 for produced ethernet frames
  */
 
 #include "vl.h"
@@ -1732,6 +1735,25 @@
 return ret;
 }
 
+static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size, int do_interrupt)
+{
+if (!size)
+{
+DEBUG_PRINT(("RTL8139: +++ empty ethernet frame\n"));
+return;
+}
+
+if (TxLoopBack == (s->TxConfig & TxLoopBack))
+{
+DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
+rtl8139_do_receive(s, buf, size, do_interrupt);
+}
+else
+{
+qemu_send_packet(s->vc, buf, size);
+}
+}
+
 static int rtl8139_transmit_one(RTL8139State *s, int descriptor)
 {
 if (!rtl8139_transmitter_enabled(s))
@@ -1762,15 +1784,7 @@
 s->TxStatus[descriptor] |= TxHostOwns;
 s->TxStatus[descriptor] |= TxStatOK;
 
-if (TxLoopBack == (s->TxConfig & TxLoopBack))
-{
-DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
-rtl8139_do_receive(s, txbuffer, txsize, 0);
-}
-else
-{
-qemu_send_packet(s->vc, txbuffer, txsize);
-}
+rtl8139_transfer_frame(s, txbuffer, txsize, 0);
 
 DEBUG_PRINT(("RTL8139: +++ transmitted %d bytes from descriptor %d\n", txsize, descriptor));
 
@@ -1831,6 +1845,9 @@
 #define CP_TX_LS (1<<28)
 /* large send packet flag */
 #define CP_TX_LGSEN (1<<27)
+/* large send MSS mask, bits 16...25 */
+#define CP_TC_LGSEN_MSS_MASK ((1 << 12) - 1)
+
 /* IP checksum offload flag */
 #define CP_TX_IPCS (1<<18)
 /* UDP checksum offload flag */
@@ -1885,6 +1902,8 @@
 s->cplus_txbuffer_len = CP_TX_BUFFER_SIZE;
 s->cplus_txbuffer = malloc(s->cplus_txbuffer_len);
 s->cplus_txbuffer_offset = 0;
+
+DEBUG_PRINT(("RTL8139: +++ C+ mode transmission buffer allocated space %d\n", s->cplus_txbuffer_len));
 }
 
 while (s->cplus_txbuffer && s->cplus_txbuffer_offset + txsize >= s->cplus_txbuffer_len)
@@ -1960,16 +1979,19 @@
 s->cplus_txbuffer_offset = 0;
 s->cplus_txbuffer_len = 0;
 
-if (txdw0 & (CP_TX_IPCS | CP_TX_UDPCS | CP_TX_TCPCS))
+if (txdw0 & (CP_TX_IPCS | CP_TX_UDPCS | CP_TX_TCPCS | CP_TX_LGSEN))
 {
 DEBUG_PRINT(("RTL8139: +++ C+ mode offloaded task checksum\n"));
 
 #define ETH_P_IP	0x0800		/* Internet Protocol packet	*/
 #define ETH_HLEN14
+#define ETH_MTU 1500
 
 /* ip packet header */
 register struct ip *ip = 0;
 int hlen = 0;
+u_int8_t  ip_protocol = 0;
+u_int16_t ip_data_len = 0;
 
 struct mbuf local_m;
 
@@ -1989,6 +2011,8 @@
 ip = NULL;
 } else {
 hlen = ip->ip_hl << 2;
+ip_protocol = ip->ip_p;
+ip_data_len = ntohs(ip->ip_len) - hlen;
 }
 }
 
@@ -2010,12 +2034,118 @@
 }
 }
 
-if (txdw0 & (CP_TX_TCPCS|CP_TX_UDPCS))
+if ((txdw0 & CP_TX_LGSEN) && ip_protocol == IPPROTO_TCP)
 {
-DEBUG_PRINT(("RTL8139: +++ C+ mode need TCP or UDP checksum\n"));
+int large_send_mss = (txdw0 >> 16) & CP_TC_LGSEN_MSS_MASK;
+
+DEBUG_PRINT(("RTL8139: +++ C+ mode offloaded task TSO MTU=%d IP data %d frame data %d specified MSS=%d\n",
+ ETH_MTU, ip_data_len, saved_size - ETH_HLEN, large_send_mss));
+
+int tcp_send_offset = 0;
+int send_count = 0;
+
+//ip_data_len = saved_size - ETH_HLEN;
+
+/* maximum IP header length is 60 bytes */
+uint8_t saved_ip_header[60];
+
+/* save IP header template; data area is used in tcp checksum calculation */
+memcpy(saved_ip_header, local_m.m_data, hlen);
+
+/* a placeholder for checksum calculation routine in tcp case */
+struct mbuf local_checksum_m;
+
+ 

RE: [Qemu-devel] qemu/hw rtl8139.c

2006-07-04 Thread ZIGLIO, Frediano, VF-IT
> 
> CVSROOT:  /sources/qemu
> Module name:  qemu
> Changes by:   Fabrice Bellard06/07/04 10:08:36
> 
> Modified files:
>   hw : rtl8139.c 
> 
> Log message:
>   rtl8139 fixes (Igor Kovalenko)
> 
> CVSWeb URLs:
> http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=
qemu&r1=1.2&r2=1.3
> 

I can confirm that win64 is still happy !!!

freddy77



___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[Qemu-devel] qemu/hw rtl8139.c

2006-07-04 Thread Fabrice Bellard
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Fabrice Bellard06/07/04 10:08:36

Modified files:
hw : rtl8139.c 

Log message:
rtl8139 fixes (Igor Kovalenko)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.2&r2=1.3


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


Re: [Qemu-devel] qemu/hw rtl8139.c

2006-07-03 Thread Paul Brook
On Saturday 01 July 2006 22:41, Fabrice Bellard wrote:
> Modified files:
>   hw : rtl8139.c
>
> Log message:
>   disable unimplemented C+ mode (aka windows xp 64 fix)

I'm not sure I believe this.  C+ mode works fine in linux, and on a simple TCP 
throughput test was ~20% faster.

Paul


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[Qemu-devel] qemu/hw rtl8139.c

2006-07-01 Thread Fabrice Bellard
CVSROOT:/sources/qemu
Module name:qemu
Changes by: Fabrice Bellard06/07/01 21:41:18

Modified files:
hw : rtl8139.c 

Log message:
disable unimplemented C+ mode (aka windows xp 64 fix)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/hw/rtl8139.c?cvsroot=qemu&r1=1.1&r2=1.2


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel