func: static void rtl8139_io_writeb(void *opaque, uint8_t addr, uint32_t val) RTL8139State * s = opaque ; switch ( addr )  if ( val == 'R' )  if ( val == 'H' )  s -> clock_enabled = 0; s -> TxThresh = val; if ( val & ( 1 << 6 ) )  rtl8139_cplus_transmit ( s ); static void rtl8139_cplus_transmit(RTL8139State *s) while ( rtl8139_cplus_transmit_one ( s ) )  static int rtl8139_cplus_transmit_one(RTL8139State *s) if ( ! rtl8139_transmitter_enabled ( s ) )  static int rtl8139_transmitter_enabled(RTL8139State *s) return s -> bChipCmdState & CmdTxEnb ; if ( ! rtl8139_cp_transmitter_enabled ( s ) )  static int rtl8139_cp_transmitter_enabled(RTL8139State *s) return s -> CpCmd & CPlusTxEnb ; uint32_t val , txdw0 , txdw1 , txbufLO , txbufHI ; txdw0 = le32_to_cpu ( val ); txdw1 = le32_to_cpu ( val ); if ( ! ( txdw0 & CP_TX_OWN ) )  if ( txdw0 & CP_TX_FS )  s -> cplus_txbuffer_offset = 0; int txsize = txdw0 & CP_TX_BUFFER_SIZE_MASK ; if ( ! s -> cplus_txbuffer )  s -> cplus_txbuffer_len = CP_TX_BUFFER_SIZE; s -> cplus_txbuffer = g_malloc ( s -> cplus_txbuffer_len ); s -> cplus_txbuffer_offset = 0; if ( s -> cplus_txbuffer_offset + txsize >= s -> cplus_txbuffer_len )  txsize = s -> cplus_txbuffer_len - s -> cplus_txbuffer_offset; s -> cplus_txbuffer_offset += txsize; if ( txdw0 & CP_TX_EOR )  s -> currCPlusTxDesc = 0; if ( s -> currCPlusTxDesc >= 64 )  s -> currCPlusTxDesc = 0; txdw0 &= ~CP_RX_OWN; txdw0 &= ~CP_TX_STATUS_UNF; txdw0 &= ~CP_TX_STATUS_TES; txdw0 &= ~CP_TX_STATUS_OWC; txdw0 &= ~CP_TX_STATUS_LNKF; txdw0 &= ~CP_TX_STATUS_EXC; if ( txdw0 & CP_TX_LS )  uint8_t dot1q_buffer_space [ VLAN_HLEN ] ; uint16_t * dot1q_buffer ; uint8_t * saved_buffer = s -> cplus_txbuffer ; if ( txdw1 & CP_TX_TAGC )  dot1q_buffer = ( uint16_t * ) dot1q_buffer_space; dot1q_buffer [ 0 ] = cpu_to_be16 ( ETH_P_8021Q ); dot1q_buffer [ 1 ] = cpu_to_le16 ( txdw1 & CP_TX_VLAN_TAG_MASK ); dot1q_buffer = NULL; s -> cplus_txbuffer = NULL; s -> cplus_txbuffer_offset = 0; s -> cplus_txbuffer_len = 0; if ( txdw0 & ( CP_TX_IPCS | CP_TX_UDPCS | CP_TX_TCPCS | CP_TX_LGSEN ) )  ip_header * ip = NULL ; int hlen = 0 ; uint8_t ip_protocol = 0 ; uint16_t ip_data_len = 0 ; uint8_t * eth_payload_data = NULL ; int proto = be16_to_cpu ( * ( uint16_t * ) ( saved_buffer + 12 ) ) ; if ( proto == ETH_P_IP )  eth_payload_data = saved_buffer + ETH_HLEN; ip = ( ip_header * ) eth_payload_data; if ( IP_HEADER_VERSION ( ip ) != IP_HEADER_VERSION_4 )  ip = NULL; hlen = IP_HEADER_LENGTH ( ip ); ip_protocol = ip -> ip_p; ip_data_len = be16_to_cpu ( ip -> ip_len ) - hlen; if ( ip )  if ( ( txdw0 & CP_TX_LGSEN ) && ip_protocol == IP_PROTO_TCP )  tcp_header * p_tcp_hdr = ( tcp_header * ) ( eth_payload_data + hlen ) ; int tcp_hlen = TCP_HEADER_DATA_OFFSET ( p_tcp_hdr ) ; int tcp_data_len = ip_data_len - tcp_hlen ; int tcp_chunk_size = ETH_MTU - hlen - tcp_hlen ; for (tcp_send_offset = 0; tcp_send_offset < tcp_data_len; tcp_send_offset += tcp_chunk_size) uint16_t chunk_size = tcp_chunk_size ; if ( tcp_send_offset + tcp_chunk_size >= tcp_data_len )  chunk_size = tcp_data_len - tcp_send_offset; int tso_send_size = ETH_HLEN + hlen + tcp_hlen + chunk_size ; rtl8139_transfer_frame ( s , saved_buffer , tso_send_size , 0 , ( uint8_t * ) dot1q_buffer ); static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int int do_interrupt, const uint8_t *dot1q_buf) struct iovec * iov = NULL ; struct iovec vlan_iov [ 3 ] ; if ( ! size )  if ( dot1q_buf && size >= ETHER_ADDR_LEN * 2 )  iov = ( struct iovec [ 3 ] . iov_base = buf , . iov_len = ETHER_ADDR_LEN * 2 . iov_base = ( void * ) dot1q_buf , . iov_len = VLAN_HLEN . iov_base = buf + ETHER_ADDR_LEN * 2 . iov_len = size - ETHER_ADDR_LEN * 2 , memcpy ( vlan_iov , iov , sizeof ( vlan_iov ) ); iov = vlan_iov; if ( iov )  buf2_size = iov_size ( iov , 3 ); buf2 = g_malloc ( buf2_size ); iov_to_buf ( iov , 3 , 0 , buf2 , buf2_size ); buf = buf2; rtl8139_do_receive ( qemu_get_queue ( s -> nic ) , buf , size , do_interrupt ); if ( iov )  g_free ( buf2 ); if ( iov )  qemu_sendv_packet ( qemu_get_queue ( s -> nic ) , iov , 3 ); qemu_send_packet ( qemu_get_queue ( s -> nic ) , buf , size ); 