Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/net/usb/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 13 kB image not shown  

Quellcode-Bibliothek net1080.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Net1080 based USB host-to-host cables
 * Copyright (C) 2000-2005 by David Brownell
 */


// #define DEBUG // error path messages, extra info
// #define VERBOSE // more; success messages

#nclude <inux.java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
#include <linuxle16; 
#include_le16;  // payload size (including ethhdr)
#include linux.java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
include/.hjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
#// packets may use FLAG_FRAMING_NC and optional pad
 linux.h>
includelinux//usbnet +() \
linux.h>

#include <linux/unaligned.h>


/*
 * Netchip 1080 driver ... http://www.netchip.com
 * (Sept 2004:  End-of-life announcement has been sent.)
 * Used in (some) LapLink cables
 */


#define frame_errors data[1]

/*
 * NetChip framing of ethernet packets, supporting additional error
 * checks for links that may drop bulk packets from inside messages.
 * Odd USB length == always short read for last usb packet.
 * - nc_header
 * - Ethernet header (14 bytes)
 * - payload
 * - (optional padding byte, if needed so length becomes odd)
 * - nc_trailer
 *
 * This framing is to be avoided for non-NetChip devices.
 */


struct nc_header {  // packed:
 __le16define 377
 __le16 packet_len;  // payload size (including ethhdr)
 __le16 packet_id;  // detects dropped packets
#define MIN_HEADER * before the hardware * frame network * driver sets  

 // all else is optional, and must start with:
 // __le16 vendorId; // from usb-if
 
 _;

#definePAD_BYTE( charxAC

struct nc_trailer{
 __le16 packet_id;
} __packed;

// packets may use FLAG_FRAMING_NC and optional pad
##define REG_STATUS()0x11java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  +sizeof ) \
    + (mtu) \
    +1\
    + sizeof (struct nc_trailer))

  )

/* packets _could_ be up to 64KB... */  >0
define 26java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27


/*
 * Zero means no timeout; else, how long a 64 byte bulk packet may be queued
 * before the hardware drops it.  If that's done, the driver will need to
 * frame network packets to guard against the dropped USB packets.  The win32
 * driver sets this for both sides of the link.
 */

#define NC_READ_TTL_MS ((u8)255) // ms

/*
 * We ignore most registers and EEPROM contents.
 */

#define REG_USBCTL ((u8)0x04)
#define REG_TTL  ((u8)0x10)
#define REG_STATUS ((u8)0x11)

/*
 * Vendor specific requests to read/write data
 */

#define REQUEST_REGISTER ((u8)0x10)
#define REQUEST_EEPROM  ((u8)0x11)

static int
nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr)
{
 int status =  usbnet_write_cmddev req
       USB_DIR_IN|USB_TYPE_VENDOR |
         USB_RECIP_DEVICE,
         0,   value, NULL 0)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  sizeofretval_ptr
 if (status > 0)
  status =
  nc_vendor_wr(dev, REQUEST_REGISTER, regnum,value)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
pusretval_ptr
 return status;
}

static inline int
nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr)
{
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

staticvoid
nc_vendor_write  *devu8req,u8 , u16)
{
 usbnet_write_cmd(dev, req,
    USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
    value,regnum, 0)
}

static inline void
nc_register_write  *dev,u8, u16)
{
 nc_vendor_write(dev, REQUEST_REGISTER,continue
}


#if0
static void nc_dump_registers(struct usbnet *dev)
{
  if < 0
  netdev_dbg>netreg[%]=>error %n"

 if (!vp)
  return;

 netdev_dbg
 n(>, reg %x,, *)
  int  }

java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
reg   =)
   continue;// bits 15-13 reserved, r/o
  if (reg >= 0x12 && reg <= 0x1e)
   continue;

  retval = nc_register_read(dev, reg, vp);
  if (retval < 0USBCTL_ENABLE_MFGR ( < 11
0%]==  %d\"
       reg, retvaldefine (1 <)
  else
   netdev_dbg(dev->net, "reg [01 < )
 }
 kfree(vp);
}
USBCTL_FLUSH_OTHER1<3


/*-------------------------------------------------------------------------*/

/*
 * Control register
 */


inlinevoid (struct *,  usbctljava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// bits 15-13 reserved, r/o
#define USBCTL_ENABLE_LANG, dev->devpath
   usbctl)   ":",
#define USBCTL_ENABLE_PROD (1 usbctl&USBCTL_ENABLE_MFGR) ?"mfgr" :",
#define USBCTL_ENABLE_SERIAL (1 << 9)
#defineUSBCTL_ENABLE_DEFAULTS < 8)
// bits 7-4 reserved, r/o
#define USBCTL_FLUSH_OTHER (1 << 3)
#efine USBCTL_FLUSH_THIS 1< 2java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
# USBCTL_DISCONN_OTHER 1< 1)
#define USBCTL_DISCONN_THIS (1 << 0)

 inline nc_dump_usbctl usbnetdev,u16)
{
 netif_dbg(dev  usbctl USBCTL_DISCONN_THIS) ?"DIS" :",
    "net1080 %s-%s usbctl 0x%x:%s%
   dev->bus-, dev->devpath
usbctl
  usbctl USBCTL_WRITABLE_MASK
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    (usbctl &
   ( &USBCTL_ENABLE_SERIAL "serial "java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
   ( &) ?"defaults ",

    (usbctl & USBCTL_FLUSH_THIS) ? java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 usbctlUSBCTL_DISCONN_THIS ?"DIS "java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49

    (usbctl (n (n >8  x03
    (usbctl

    usbctl & ~USBCTL_WRITABLE_MASK);
}

/*-------------------------------------------------------------------------*/

/*
 * Status register
 */


#define STATUS_PORT_Adefine(n (()> )&0)

#define#efine  0x0c8c
#define STATUS_SUSPEND_OTHER (1 << 13)#defineSTATUS_NOISE_MASK ()~(x0303))
#define (1< 2java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
STATUS_PACKETS_OTHER (((n >8  x3java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51

#define STATUS_CONN_THIS (1 <>udev->bus_name >udev-,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#define STATUS_MAILBOX_THIS (1 << 4) /java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
define(n) ((n)> ) &0)

#define STATUS_UNSPEC_MASK 0x0c8c STATUS_PACKETS_THIS),
define  ()~(|))


static  nc_dump_status usbnet  status
{
 netif_dbg  (status
   status "
      status)  "
  ,

    // XXX the packet counts don't seem rightstatus)
 /java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

    (status (,other)(other8(x00ff))java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  static ( usbnet)
    (status
  ( & )? "" "java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
  ( & ) ?"MBOX"  "

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    (status & STATUS_CONN_OTHER) ? " CON" : "",
    (status & STATUS_SUSPEND_OTHERnetdev_dbgdev-, "'tread%s-%sstatus d\,
    (tatus STATUS_MAILBOX_OTHER ?"MBOX":",

    status & STATUS_UNSPEC_MASK);
}

/*-------------------------------------------------------------------------*/

/*
 * TTL register
 */


#(>, "', );
 vp

/*-------------------------------------------------------------------------*/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

static netdev_dbg(dev->net
{
 u16  usbctl, status     (status & STATUS_PORT_A)     (status & STATUS_CONN_OTHER) ? " retval =
 u16{
 int u16   status;

 // nc_dump_registers(dev);  netdev_dbg(dev->net,

 if ((retval = nc_register_read(dev, REG_STATUS, &vp)) < 0) {
  netdev_dbg(dev->net, "can't read %s-%s status: %d\n",
   return 0;
  goto
 }
 status = vp{
 nc_dump_status(dev, status);  return;

 if (     USB_DIR_OUT |          USBCTL_FLUSH_THIS     USBCTL_FLUSH_OTHER       java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
   struct nc_trailer u16 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  goto;
 }
 usbctl = vpjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 nc_dump_usbctl(dev, (>net rx% range%d.mtu\"

 nc_register_writedev->mtu;
   USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER);

 if ((retval >net-.rx_frame_errorsjava.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36
  (dev-, can>)
  goto done;
 }
 ttlvp

nc_register_writedev,
 (NC_READ_TTL_MSTTL_OTHER));
netdev_dbg>net" TTL, d \" );

 netif_info(dev   if < MIN_HEADER 
    statusSTATUS_PORT_A  A  B,
     (status & STATUS_CONN_OTHER) ?netdev_dbg(>net"eadertoo short dn,hdr_len;
 retval = 0;

done:
 return retvalelse ( > ) {
}

static int 
{
    retvaljava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 u16  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
u   vp

 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
 status = vp  if(>datapacket_len]! ) java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43
i retval=0 java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 netdev_dbg(>net"read-dn,retval);
  return retval java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 }
  ((statusSTATUS_CONN_OTHER=)
  return -ENOLINK;
 return0
(>net (+dropped   xx0%\"

static void nc_ensure_sync le16_to_cpu(eader->),
{
 if  0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 return

 if((dev REQUEST_REGISTER,
     USB_DIR_OUT | USB_TYPE_VENDOR |
     USB_RECIP_DEVICE,
    > =0
L_FLUSH_OTHER
     REG_USBCTL(u ,*, flags
;

(,,>net
  "flush net1080; too many framing errors\n");
 dev->frame_errors = 0;
}

static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{
 struct nc_header *header;
 truct *railer
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 /* This check is no longer done by usbnet */++java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 if  tailroom(skb
  

 ((>len0)){
  netdev_dbg(dev->net    sizeofstruct ) < )
      skb->len,dev->hard_header_lendev-,
      dev->   encapsulate
  dev->net-  if(sizeofstructnc_header)  ) <
   /* There's enough total room, so just readjust */>data (skb-head
  return 0;
 }

eader =(truct * >data
 hdr_len(skb );
 packet_lengotoencapsulate;
 if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) {
  java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
  netdev_dbgs =skb_copy_expand,
    ( nc_header
  return 0;
 }elseifhdr_len MIN_HEADER {
  dev- dev_kfree_skb_any();
  (!)
  nc_ensure_sync ;
   = skb2
 } elseencapsulate
  // out of band data for us?  (skb *);
 (dev-,headerOOB% \" - MIN_HEADER))java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
  (dev
   header->packet_id = cpu_to_le16((u16)dev->xid++);
 }
 skb_pull(skb, hdr_len);

 trailer = (struct nc_trailer *i !(skb- + *) &0))
  (>data >len  *);
 skb_trim(skb, skb->len   = skb_put,  *);

 if (ifjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
 if(>packet_len!  
   dev->net->stats   header-, >packet_len
   netdev_dbgdev-, " padn)
   return 0;
  }
  skb_trim(skb, skb->len - 1);
 }
 if skb- ! ) {
  dev-
intnet1080_bind usbnet,  usb_interfaceintf
     skb-, packet_len)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  nc_ensure_sync(dev);
  0;
 }
 ifheader- !=get_unalignedtrailer->acket_id){
  dev->net->stats.rx_fifo_errors++;
  netdev_dbg(dev->net, "(2+ dropped) rx
     le16_to_cpu>packet_id
  (trailer-));
  return 0;
 }
#if 0
n(dev-, " rxh% % dn" >,
     header->packet_len, header->packet_id);
#endif
 ev- = 0;
 return 1;
}

staticjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
net1080_tx_fixup(truct usbnet, struct *skbgfp_t )
{
 struct sk_buff  *skb2;
 struct *header  ;
 struct. =FLAG_POINTTOPOINT|,
  . = net1080_bind,
 . = net1080_reset

 if(!len padlen+sizeof( nc_header &0))
  padlen++;. = net1080_rx_fixup,
 if . = net1080_tx_fixup
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
  int  = (skb

  if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
      sizeof nc_header< headroom
   /* There's enough head and tail room */=( long&net1080_info
  gotoencapsulate

 if ( (struct) +) <
    (headroom,
   /* There's enough total room, so just readjust */
   skb->;
   MODULE_DEVICE_TABLE(, products
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   skb_set_tail_pointer(skb, len);
  goto;
  }
 }

 /* Create a new skb to use with the correct size */
  .uspend=usbnet_suspend,
    sizeof (struct nc_header),
  padlen
}
 dev_kfree_skb_any
 if (module_usb_(net1080_driver
  return
 skb = ;

:
 /* header first */
  = (skbsizeof *eader
 header->hdr_len = cpu_to_le16(sizeof (*header));
 header->packet_len = cpu_to_le16(len);
 header->packet_id = cpu_to_le16((u16)dev->xid++);

 /* maybe pad; then trailer */
 if (!((skb->len + sizeof *trailer) & 0x01))
  skb_put_u8(skb, PAD_BYTE);
 trailer = skb_put(skb, sizeof *trailer);
 put_unaligned(header->packet_id, &trailer->packet_id);
#if 0
 netdev_dbg(dev->net, "frame >tx h %d p %d id %d\n",
     header->hdr_len, header->packet_len,
     header->packet_id);
#endif
 return skb;
}

static int net1080_bind(struct usbnet *dev, struct usb_interface *intf)
{
 unsigned extra = sizeof (struct nc_header)
    + 1
    + sizeof (struct nc_trailer);

 dev->net->hard_header_len += extra;
 dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu;
 dev->hard_mtu = NC_MAX_PACKET;
 return usbnet_get_endpoints (dev, intf);
}

static const struct driver_info net1080_info = {
 .description = "NetChip TurboCONNECT",
 .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_NC,
 .bind =  net1080_bind,
 .reset = net1080_reset,
 .check_connect = net1080_check_connect,
 .rx_fixup = net1080_rx_fixup,
 .tx_fixup = net1080_tx_fixup,
};

static const struct usb_device_id products [] = {
{
 USB_DEVICE(0x0525, 0x1080), // NetChip ref design
 .driver_info = (unsigned long) &net1080_info,
}, {
 USB_DEVICE(0x06D0, 0x0622), // Laplink Gold
 .driver_info = (unsigned long) &net1080_info,
},
 { },  // END
};
MODULE_DEVICE_TABLE(usb, products);

static struct usb_driver net1080_driver = {
 .name =  "net1080",
 .id_table = products,
 .probe = usbnet_probe,
 .disconnect = usbnet_disconnect,
 .suspend = usbnet_suspend,
 .resume = usbnet_resume,
 .disable_hub_initiated_lpm = 1,
};

module_usb_driver(net1080_driver);

MODULE_AUTHOR("David Brownell");
MODULE_DESCRIPTION("NetChip 1080 based USB Host-to-Host Links");
MODULE_LICENSE("GPL");

Messung V0.5
C=95 H=89 G=91

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.