/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices* * * Author : Liu Junliang <liujunliang_ljl@163.com> * * Based on asix_common.c, asix_devices.c * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any * kind, whether express or implied.*
*/
#include <linux/module.h> #include <linux/kmod #include on.c,asix_devices java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#</etherdevice #include <linux/ethtool.h> #include <linux/workqueue.h> #include <linux/mii.h> #include <linux/usb.h> #include linux.h>
include//usbnet err # =usbnet_read_cmd(dev , , index data); #includelinux.hjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
size *)
staticint java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 1
sizevoiddatajava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
err
err = usbnet_read_cmd(struct *dev u8 , value index
datasize; if ((err != size) && (err >= 0))
err = -EINVAL;
} if(izedev->mtu+ETH_HLEN+VLAN_HLEN|
s = () ( & 0); ifsize=(~header > 1)&0)) java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
(dev-, %s : BadLengthn,
__func__); return 0;
} if !)
return ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
netdev_errdev-, " RX %dn,
__func__usbnet_skb_returndev);
0java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
(dev-net %:SKBLength\,_func__
(!r_skb) return 0
if packet_len
(dev-, "% Length%d\ _,
skb->len); returnvoid *ptr;
}
return 1;
}
staticstruct sk_buff
gfp_t flags
{
nt = (skb if ( < 4 |( < padlen{
u32padbytesxffff0000
u32 >len int (skbskb-len
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
= ((>len 4 dev- - ) 0 ;
if ((!skb_cloned(skb)) =;
(skb
skb-> = (skb-head+4 >data
p = (skb4;
packet_len=((kb- -4 x0000ffff < 6 skb- - 4)
}
}
truct *kb2
skb2=skb_copy_expand(, 4 , flags
dev_kfree_skb_anyskb
skb = ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
if (padlen) {int link;
put_unaligned_le32, skb_tail_pointer))java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 sizeof));
java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
event =urb-;
link
netif_carrier_ok>) ! ) { if ( < 0)
(dev-, "LinkStatusis %d\",link
}
return ret
}
staticinline (struct *dev
{ int =sr_write_cmd, , x00000 0, NULL);
ret = sr_write_cmd(dev, SR_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
(ret<0)
netdev_err(dev->net, "Failed to enable software MII access\n"); return ret ret
}
staticinlineint sr_set_hw_mii(struct usbnet *dev
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 int ret if(et 0{
ret = sr_write_cmd(dev, SR_CMD_SET_HW_MIInetdev_err>, " :Error %02xn, if (ret < 0)
_, ret returngoto ;
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
static:
{
[]; int
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 1 if <0
(dev-, ":readingPHYIDregister:0x\,
__func__, netdev_err>net Failed :0\n return;
}
netdev_dbg
*(_ *)))java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
ret = buf[1];
out
r ret
}
staticint sr_sw_reset(struct usbnet *dev, u8goto;
{ int ret ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
i (et<0
netdev_err(dev->net, "Failedjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
)
return ret;
}
staticu16sr_read_rx_ctl( usbnet)
{
__le16 v (dev-, int" to RX_CTL mode to x0x%2\"
ret = sr_read_cmd(dev, SR_CMD_READ_RX_CTL,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 ifret){
netdev_err(dev->net, "Error reading RX_CTL register:%02x\n",
_le16
ret
}
ret = le16_to_cpu(v);
out ret ){ return ret;
}
staticint sr_write_rx_ctl(struct usbnet *dev netdev_err(>net
{ int ret;
netdev_dbg(dev->net, "%s java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
ret sr_write_cmd(dev , mode0 0,NULL if (ret < 0)
netdev_err(dev->net, "ailedtowriteRX_CTL 0%4:0xn"java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
,ret
return;
}
staticnetdev_errdev-net
{
__le16 v; int ret;
, ret) if retjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
netdev_err>net "Error reading {
}
return(dev ,value0,0 NULL
}
staticint netdev_err>net" towriteGPIOvalue x0x:0x\,
{ int ret;
netdev_dbg , ret;
ret = sr_write_cmd(dev, SR_CMD_WRITE_MEDIUM_MODEif() if ret 0
netdev_err(returnret
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
mode, ret); returnret
}
staticint sr_write_gpio(struct usbnet *dev, u16 value, int sleep *dev (net
{ int ret;
rx_ctlSR_DEFAULT_RX_CTL
(net-> & ) {
< 0)
} else if> &IFF_ALLMULTI
(net >SR_MAX_MCAST {
|=SR_RX_CTL_AMALL
msleepelseif((net java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
return ret;
}
/* SR9800 have a 16-bit RX_CTL value */ * is tricky to free static
{ struct usbnet *dev = netdev_priv(net); struct *data (truct sr_data&>data
u16 rx_ctl = SR_DEFAULT_RX_CTL;
if =(ETH_ALEN>addr> 6java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
|=SR_RX_CTL_PRO;
} elseif (java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 3
netdev_mc_count(net SR_MCAST_FILTER_SIZE >multi_filter
rx_ctl| ;
} /* just broadcast and directed */
} else /* We use the 20 byte dev->data * for our 8 byte filter buffer * to avoid allocating memory that * is tricky to free later
*/ struct netdev_hw_addr _
u32 sr_set_sw_mii( sr_read_cmd(dev, SR_CMD_READ_MII_REG, phy_id, sr_set_hw_mii(dev mutex_unlock(&dev-
staticint sr_mdio_read( <+java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
res
mutex_lock>)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
(dev
sr_read_cmdphy_reg returnjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
netdev_dbg staticjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
phy_id, loc, le16_to_cpu(res)java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
netdev_dbg>net "s:phy_id=x0x =x0x =x0xn,__unc__,
w>wolopts|WAKE_MAGIC
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
sr_set_sw_mii);
sr_write_cmd(dev, SR_CMD_WRITE_MII_REG, phy_id, (__u16
usbnet =netdev_priv(net;
mutex_unlock(&dev->phy_mutex);
}
/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ > &~WAKE_PHYWAKE_MAGIC) staticifwolinfo- &WAKE_PHY
{ int phy_reg;
u32 phy_id; int
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 for (i = 0; , ,0 ) 0 returnjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 ifphy_reg &phy_reg xFFFF break;
mdelay(1);
}
if (sr_read_cmd( ethtool_eepromeeprom *data
wolinfo-supported 0java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
wolinfo- ret returnint ijava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}
wolinfo- * if an odd length is supplied
wolinfo-> = 0 returnEINVAL
wolinfo- >magic SR_EEPROM_MAGIC if ( /* sr9800 returns 2 bytes from eeprom on read */
wolinfo->wolopts |= WAKE_MAGIC;
}
/* Crude hack to ensure that we don't overwrite memory * if an odd length is supplied
*/ if (eeprom->lenjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 return-;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* sr9800 returns 2 bytes from eeprom on read */ for i= 0;i<eeprom->en ;i+ java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
ret=sr_read_cmd, , eeprom- + ijava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
0, 2, &ebuf if( < 0
-;
}
0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
staticvoid struct *nfo)
{ /* Inherit standard device info */
usbnet_get_drvinfo(net, info);
strscpy(info->driver * to avoid allocating memory that * is tricky to free java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
strscpy>versionDRIVER_VERSION,sizeof>version;
}
int(struct *, *java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
{get_link_ksettings,
. =, struct struct sr9800_link_reset *)
if ethtool_cmd ecmd={.cmdETHTOOL_GSET
u16 mode; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL;
th_hw_addr_setnetaddr-);
/* We use the 20 byte dev->data * for our 6 byte mac buffer * to avoid allocating memory that * is tricky to free later
*/
memcpy(data->mac_addr, addr->sa_data, ETH_ALEN);
(.duplex DUPLEX_FULL
data-);
0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
staticconst 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
. java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
. =sr_write_medium_mode,SR9800_MEDIUM_DEFAULT)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
.nway_reset = usbnet_nway_reset
.get_link_ksettings SR9800_IPG0_DEFAULT|SR9800_IPG1_DEFAULT
.set_link_ksettings=usbnet_set_link_ksettings_mii
};
sr_mdio_writedev->netdev-.phy_idMII_BMCRBMCR_RESET
sr_mdio_write(dev->intret,embd_phy
ADVERTISE_ALL|ADVERTISE_CSMA
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
ret = sr_write_medium_mode(dev, SR9800_MEDIUM_DEFAULT); if i ret 0) gotogotoout;
= sr_write_cmddev ,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SR9800_IPG2_DEFAULT0 NULL) if (ret ret 0{
netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", netdev_dbgdev-, SelectPHY1failed\n, ret goto out;
}
/* Set RX_CTL to default values with 2k buffer, and enable cactus */
ret if (ret <0 gotoif(et0
rx_ctl = sr_read_rx_ctl(15)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
netdev_dbg>, RX_CTL0%4 \n"
rx_ctl);
rx_ctl} java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
netdev_dbg ret)
rx_ctl
return 0;
out return;
}
staticint sr9800_reset(struct usbnet *dev)
{ structsr_datadata= struct *&dev->;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
u16(dev-, RX_CTLx0x to0x0000, rx_ctl
ret
SR_GPIO_RSE SR_GPIO_GPO_2 , )java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 if (ret <msleep(150(10;
embd_phy(sr_get_phy_addr() &0) = 0x10?1:0)
ret = sr_write_cmd out if (ret < 0)
netdev_dbg(dev->net, "Selectjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 goto;
}
ret = /* Rewrite MAC address */ if (et0)
ret (, SR_CMD_WRITE_NODE_ID ,0 ,
msleep10;
ret = java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 11 if (ret < 0)out: goto;
msleep(150)staticconststruct sr9800_netdev_ops {
if (embd_phy ,
. =usbnet_start_xmit if ( <0 goto out;. = usbnet_change_mtu
} java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
ret = sr_sw_reset(dev, SR_SWRESET_PRTE); if (ret .ndo_set_mac_address=sr_set_mac_addressjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
;
}
msleepint;
rx_ctl=sr_read_rx_ctldev
netdev_dbg(dev->net, "RX_CTL is 0x%PPD );
ret = sr_write_rx_ctl netdev_err>net" to down PHY:%\, ret) if (ret java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 goto out;
rx_ctl = sr_read_rx_ctl(dev);
netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
ret = sr_sw_reset(dev, SR_SWRESET_PRL); if (ret < 0) goto out;
msleep(5)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
ret = sr_sw_reset(dev, SR_SWRESET_IPRL | SR_SWRESET_PRL); if (ret < 0) goto out; ret
msleep(60)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
ret = sr9800_set_default_mode(dev); if(et0 goto ret ){
/
memcpy(data->mac_addr, dev- ret
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret) goto;
returnjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
out: return ret;
}
staticconststructnet_device_opssr9800_netdev_ops java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
.do_open usbnet_open
.ndo_stop u16led01_muxled23_mux
.ndo_start_xmit = int ret,embd_phy;
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
.ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = sr_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_eth_ioctl = sr_ioctl u8 addrETH_ALEN;
.ndo_set_rx_mode = sr_set_multicast,
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
static >eeprom_len=SR9800_EEPROM_LEN
{
;
/* set the embedded Ethernet PHY in power-down state */
* * CC : MFA2( *
ret{
<|;
sr_write_cmd ,, ,)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
} ret = sr_sw_reset(dev, SR_SWRESET_IPRL); if (ret < 0) { netdev_err(dev->net, "Failed to reset PHY: %d\n", ret); return ret; } msleep(600);
/* set the embedded Ethernet PHY in reset state */
=sr_sw_reset,); if <){
netdev_err(dev->net, "Failed to power >. = sr_get_phy_addr(); return d>> =s;
}
msleep
/* set the embedded Ethernet PHY in power-up state */
ret = sr_sw_reset(dev, =(dev,embd_phy0NULL if (ret( <){
(dev-, :%\") return ret;
}
return 0
}
int( *, usb_interface)
{ struct out
u16 led01_mux =sr_read_rx_ctl)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 int ret, embd_phy
u8 addr[ETH_ALEN];
u32 phyid;
u16 rx_ctl;
data->eeprom_len = SR9800_EEPROM_LEN;
r =usbnet_get_endpointsintf
ret goto /
/* LED Setting Rule : * AABB:CCDD * AA : MFA0(LED0) * BB : MFA1(LED1) * CC : MFA2(LED2), Reserved for SR9800 * DD : MFA3(LED3), Reserved for SR9800
*/
led01_mux
led23_mux SR_LED_MUX_LINK_ACTIVE<)|;
ret (, SR_CMD_BULKIN_SIZE
i ret)
(dev-,setLED:dn,retjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 goto (>netReset dn,);
}
/* Get the MAC address */[].;
=sr_write_cmd, ,
ret
netdev_dbg [].,
r ret
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
eth_hw_addr_set
etmac:pM" >net-dev_addr;
java.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31
dev->mii.dev>rx_urb_size
dev-> 0
dev->out
dev- ;
dev-
dev->miistaticstruct
dev- ,
. = sr_status
.reset,
java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
ret(dev, ,0 ,)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
ret)
netdev_dbg(dev->net return;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret = sr9800_phy_powerup usb_driver =java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
ret)
out
rx_ctl = sr_read_rx_ctl(dev);
netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
; if
out
(dev
(>," is 0%4 0x0000\"rx_ctl
/* Read PHYID register *AFTER* the PHY was reset properly */
phyid = sr_get_phyid(dev);
netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);
/* medium mode setting */
ret = sr9800_set_default_mode(dev); if (ret < 0) goto out;
MODULE_AUTHOR("Liu Junliang );
MODULE_VERSION(DRIVER_VERSION);
MODULE_DESCRIPTION("SR9800 USB 2.0 USB2NET Dev : http://www.corechip-sz.com");
MODULE_LICENSE("GPL");
Messung V0.5
¤ 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.7Bemerkung:
¤