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

Quelle  b44.c   Sprache: C

 
/* b44.c: Broadcom 44xx/47xx Fast Ethernet device driver.)
 *
 * Copyright (C) 2002 David S. Miller (davem@redhat.com)
 * Copyright (C) 2004 Pekka Pietikainen (pp@ee.oulu.fi)
 * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
 * Copyright (C) 2006 Felix Fietkau (nbd@openwrt.org)
 * Copyright (C) 2006 Broadcom Corporation.
 * Copyright (C) 2007 Michael Buesch <m@bues.ch>
 * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
 *
 * Distribute under GPL.
 */


#define pr_fmt(fmt x400

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
#include <linux/if_ether.h>
#include <linux/#define B44_PATTERN_SIZE  x600 0
includeetherdevice
#include java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 linuxjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
</.
#include { PCI_DE(PCI_VENDOR_ID_BROADCOM)
#include ;
#include <linux/ssb(,)
#include <linux/slab    =
include.

#include java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
</java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 /.


#includejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0

#define
  Broadcom 10java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72

#define B44_DEF_MSG_ENABLE   \
 (NETIF_MSG_DRV  |java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  ,
 \
  
 
  NETIF_MSG_IFUP dma_sync_single_for_devicedma_devjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
\
     )

/* length of time before we decide the hardware is borked,
 * and dev->tx_timeout() should be called to fix the problem
 */

java.lang.NullPointerException

/* hardware minimum and maximum for a single frame's data payload */
#define B44_MIN_MTU
  java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#u32 ( )
(( )*java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
xlxn,
#define B44_TX_RING_SIZE  512
#define    ,reg "" set
define(dma_descjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
 )

#define TX_RING_GAP   datajava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 ()data<6
 ()[8
 ()[5   java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
()tx_cons)-  BP  \
   (BP)-       ()data java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 (  )-)

#definejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 5 )

/* minimum number of free TX descriptors required to wake up TX process */  ( )
#(,java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

/* b44 internal pattern match filter info */
#define B44_PATTERN_BASE 0x400 ;
0
#define B44_PMASK_BASE |
define
#define ( <)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  2

MODULE_AUTHORjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
()
MODULE_LICENSE)

   1
module_paramint
MODULE_PARM_DESC(b44_debug, " )


#ifdef CONFIG_B44_PCI
}
 { PCI_DEVICEint  bp , val
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 PCI_VENDOR_ID_BROADCOM}
 { 0

(,;

static java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  ,
 .id_table ;
;
  java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

static const struct ssb_device_id )
 _b44_writephy,;
 {},
};
MODULE_DEVICE_TABLEjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

  (*
static void  >;

#define B44_FULL_RESET  1
  java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
 ;
#define java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

static void b44_init_hw(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

intjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
int

 !{
  val java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
#undef java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

   sdev
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ,
      enum
{
(>,  +,
  b, )
}

static ( bp,  )
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
      Use ethtool
       dir
{
 (>,  +,
      )java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
}

static inline unsigned long  /h
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 return ssb_read32(  * see https  * check
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static inline 
  ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 (
 ;

  (,long
   u32java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
  java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

 for (i  ;
  ()

if& )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  (( )!)
  if java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  ;
  udelay  ;

=)
  if   =;
>BUG  0x of register %lx to %s\n"
   ,  ?clear

  return> B44_FLAG_ADV_100FULL
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 return 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static ))  )
         ;
  
 bmcr

 val  = ((u32) data[2]) << 24;
 =) [3 <6java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
   ()data <8java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
| [ ;
 bw32  ;
 (  (,MII_BMCR 
        ( ;
 
 * Since we will not be negotiating there is no safe way
bw32(bp, B44_CAM_CTRL, (CAM_CTRL_WRITE |
    (index << CAM_CTRL_INDEX_SHIFT)));
b44_wait_bit(bp, B44_CAM_CTRL, CAM_CTRL_BUSY, 100, 1);
}

static inline void __b44_disable_ints(struct b44 *bp)
{
bw32(bp, B44_IMASK, 0);
}

static void b44_disable_ints(struct b44 *bp)
{
__b44_disable_ints(bp);

/* Flush posted writes. */

(;
}

static void  ;

(>.)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}

static

 ;

( ,);
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 (>))
 phy_addr
        ( 
 (>," % ,\n,
  (flags1 ,
  >   ")

 return
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static int __b44_writephy(struct
{
 bw32(bp, java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
 i!bp-
     (,)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  bpval
   
    (;
        (val  
b44_wait_bit ,,)
}

   (b44  , *java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
{
flags
   flags

>flags
 aux

   ( ,regval
{
 ifjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  return( & BMSR_LSTATUS){

 return __b44_writephy(bp, bp->phy_addr, reg, val);
}

/* miilib interface */
static int  local_adv;
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct
 val;
 if(,)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
;
  (, )
}

static void b44_mdio_write_mii
   (dev
 java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 23
 b44_link_report
_ ,,java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
}

static int b44_mdio_read_phylibbp- n;
{
 u32b44_timert
 structjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 )
 ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
,;

  (  busint
     u16 val)
{
  =bp java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
 return>; !;  =cons
}

  =java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
{
 ;
 ;

4)
  java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
 )
  return err;
 udelay(100(dev
 err ,
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * for the RX * point the chip
   netdev_err(bp-
 -;
  }  src_map
 s  java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22

 return err;
}

static void __b44_set_flow_ctrl =NULL
{
  ;

 bp->flags &= ~(B44_FLAG_TX_PAUSE | B44_FLAG_RX_PAUSE
  (>,;

=(,);
 ifreturn;
  val   (sdev-data
 else )
  val &= ~java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(,)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

val(,B44_MAC_FLOW
 if ( ifbp-,)
 ( 
         ,)
 dev_kfree_skb_any
 (, )
if  )
}

static voidENOMEM

 ,

java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
    the b44   if (!dma_mapping_error    dma_unmap_single   dev_kfree_skb_any
    
     rh->flags
 map->skb map->mapping
  if (src_map  src_map-
     (local if (dest_idx  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                         dest_idx * sizeof(*                      DMA_BIDIRECTIONAL)
{
   pause_enab |struct ring_info  struct  int dest_idx _java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 rh = (struct rh->len rh-> dest_map->mapping =

 __b44_set_flow_ctrl(bp                    DMA_BIDIRECTIONAL
}

#ifdef  ctrljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#include <linux if (  b44_sync_dma_desc_for_device(bp-desc),
static void                  DMA_FROM_DEVICE
{
 char buf
 u32  prod  = br32 prod / cons =java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
 int   struct  u16

 /*
 * workaround for bad hardware design in Linksys WAP54G v1.0
 * see https://dev.openwrt.org/ticket/146
 * check and reset bit "isolate"
 */


   if   int i
 if    len    } while (len   if    goto  }
ifbp-&RX_COPY_THRESHOLD
  if java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    ;
 !&)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
;
  val(,)

  if ;
 
 }(cons)
 return; bp-len
error  )
   ;
}
#else
   (  *java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

 > )
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6

static +
{
u32
 ;

  () 1

 ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return
 ;
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

   * (,,java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
 ;
 
  goto >ISTAT_TX)
 ifjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
   )!
  goto>  

  bp- ;
  bp

 >  java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
    0
(flags
   adv | =(,)
 
   istat{
  if(>,);
  (;

 ;
   adv |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;

  if ((err  work_done;
   goto out;
  if
  f  ) {
  java.lang.StringIndexOutOfBoundsException: Range [20, 12) out of bounds for length 38
 }
  u32 (irqdev_id

  ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

  ;
  iflock
   bmcr ( )java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  if  * will actually raise an interrupt  * but doesn java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
bmcrjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    *       the 
*determine   supportscontrol
 _(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
*
 (,java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 }

out
 void dev )
}

static
{
   ;
 u64 *val;

 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
&>.)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

( ; =  =){
  *val++ += br32(bp, reg);
 }

 for
  *
 }  sk_buff )

 u64_stats_update_end
s    )

void  )
{
 if (!netif_carrier_ok mapping
(>,  )
 }un flags
   java.lang.StringIndexOutOfBoundsException: Range [11, 8) out of bounds for length 16
       (bp-()
   (, Ring\;

  ;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
if(>,mapping >3 java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
 }
}

static void b44_check_phy(struct b44 /* Chip can't handle DMA to/from >1GB, use bounce buffer */
{
  ;

 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 goto;
  if (
    =dma_map_single>sdev-,>data
  ,)
    val |= (>>dma_dev| + >0
   else
    if(>>,mapping
 (> ,
(>)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
bp
 (java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  return;>[s skb
 >. ;

 b44_readphy,)&
     ctrl  ;
bmsr)
  if   =java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
entry>0,
   bp->flags &= ~B44_FLAG_100_BASE_T;
  if (aux & MII_AUXCTRL_DUPLEX DMA_TO_DEVICE
    (java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  ( , sizeofjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
>&

  if (i> java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
      ((dev
   java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
   ;

   err_out
  java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
else
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
   bw32,, );

 java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 b(,MII_ADVERTISE java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
 b44_readphy )
    b44_set_flow_ctrljava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14

 spin_unlock_irq>)
 
   b44_link_report)

  ;
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    * The chip has been shut down and * the networking, so  * end up in the driver.  bp- * in an interrupt context and
  }

 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
dev  n)
  if 
 i rp-NULL
;
}

static ;
{
  * (java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51

 spin_lock_irq>)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

 b44_check_phy(rp-)

 b44_stats_updatebp-rp- >java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64

 spin_unlock_irq

 mod_timer(&bp->timer, round_jiffies(jiffies
}

 * The chip has * the networking * end up 
{
 ,;
 unsigned bytes_compl = 0, pkts_compl 

(rx_ringjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 cur(> java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64

 /* XXX needs updating when NETIF_F_SG is supported */
   >  ; NEXT_TX{
  struct ring_info,)
  struct

  ((,-   java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38

  dma_unmap_single(bp->sdev- * the  
   (  bp
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 )
>;

  bytes_compl(flagsjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
  pkts_complrx_ring

  dev_consume_skb_irq(skb);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 ,,)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
> ;
 if(>,
TX_BUFFS_AVAIL>)
  netif_wake_queue(bp->dev);

 bw32(bp}java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

/* Works like this.  This chip writes a 'struct rx_header" 30 bytes
 * before the DMA address you give it.  So we allocate 30 more bytes
 * for the RX buffer, DMA map all of it, skb_reserve the 30 bytes, then
 * point the chip at 30 bytes past where the rx_header will go.
 */

static > size
{rx_buffers
 struct java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  >)
 struct;
 struct
 java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 ;
 u32 i b)

 src_map ;
  ;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
=rx_buffersjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  + ()java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 if (skb   bp-rx_ring_dma;
  ENOMEM

 mapping = dma_map_single >  bp-dma_dev
 >,)
 )

 /* Hardware bug work-around, the chip is unable to do PCI DMA
   to/from anything above 1GB :-( */

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  mapping ,)
  /* Sigh... */;
  if (  sdma_dev
d(sdev-,
           )
(;
 ,)
  if (tx_ring_dma >DMA_BIT_MASK0{
   return -ENOMEM  ;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
,
 )
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
:
   if)
 ;
   java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
 ;
  }
  bp->force_copybreak
 }

 rh = (struct rx_header *) skb-

 rh->len = 0;
 ;

 map->skb = skb( )
>=java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24

 structbpreset_kind
  src_map->
  s >;
 ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
;

 dp 
if 
> () +)

 )
  b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dmabp,,2,;
dest_idxdp
                       DMA_BIDIRECTIONAL >=java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

 return(0java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}

static 
{
 struct dma_desc *src_desc,  * we are probably going to power down
 ring_infosrc_mapdest_mapjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  r
 int:
2;

 dest_idx = dest_idx_unmasked & (B44_RX_RING_SIZE -     ((>)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 dest_desc bw32  java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
  >[];
 java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 2

 dest_map->skb = src_map->skb;
( ,)
 rh-,;

 dest_map->mapping  (java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

 (java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
  b44_sync_dma_desc_for_cpu
                    java.lang.StringIndexOutOfBoundsException: Range [23, 24) out of bounds for length 23
 DMA_BIDIRECTIONAL

 ctrl ()
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  ()
 /* now reset the chip, but without enabling the MAC&PHY
ctrl &= cpu_to_le32(~DESC_CTRL_EOT);

dest_desc->ctrl = ctrl;
dest_desc->addr = src_desc->addr;

src_map->skb = NULL;

if (bp->flags & B44_FLAG_RX_RING_HACK)
b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma,
     dest_idx * sizeof(*dest_desc),
     DMA_BIDIRECTIONAL);

dma_sync_single_for_device(bp->sdev->dma_dev, dest_map->mapping,
   RX_PKT_BUF_SZ,
   DMA_FROM_DEVICE);
}

static int b44_rx(struct b44 *bp, int budget)
{
int received;
u32 cons, prod;

received = 0;
prod  = br32(bp, B44_DMARX_STAT) & DMARX_STAT_CDMASK;
prod /= sizeof(struct dma_desc);
cons = bp->rx_cons;

while (cons != prod && budget > 0) {
struct ring_info *rp = &bp->rx_buffers[cons];
struct sk_buff *skb = rp->skb;
dma_addr_t map = rp->mapping;
struct rx_header *rh;
u16 len;

dma_sync_single_for_cpu(bp->sdev->dma_dev, map,
RX_PKT_BUF_SZ,
DMA_FROM_DEVICE);
rh = (struct rx_header *) skb->data;
len = le16_to_cpu(rh->len);
if ((len > (RX_PKT_BUF_SZ - RX_PKT_OFFSET)) ||
    (rh->flags & cpu_to_le16(RX_FLAG_ERRORS))) {
drop_it:
b44_recycle_rx(bp, cons, bp->rx_prod);
drop_it_no_recycle:
bp->dev->stats.rx_dropped++;
goto next_pkt;
}

if (len == 0) {
int i = 0;

do {
udelay(2);
barrier();
len = le16_to_cpu(rh->len);
} while (len == 0 && i++ < 5);
if (len == 0)
goto drop_it;
}

/* Omit CRC. */

  len -= 4;

 b    )java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   skb_size = b44_alloc_rx_skb)
   if;
    goto drop_it;
   dma_unmap_single(bp-
 /* Enable CRC32, set proper LED modes and power on PHY */
    *
(, ;
   skb_pull(skbjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  } java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
   struct sk_buff *,>>   ;

   b44_recycle_rx(bp, cons, bp-   )
    ,,( |
 <);
    goto drop_it_no_recycleelse

(  +>;
 ,,java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
   skb_copy_from_linear_data_offset(skb, RX_PKT_OFFSET,
        copy_skb-bw32,,>rx_pending
   skb >  >java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
  }
  skb_checksum_none_assert(()
 bp,  )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  received++;
  budget-- bpnetdev_priv
 next_pkt
  bp->rx_prod bp)
   (B44_RX_RING_SIZE - 1);
  cons ifjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}

 bp-)
 bw32)

 return received)
}

static 0
{
 ( );
 ;
  ;

 spin_lock_irqsave(

 if timer_setup>,, ;
bp-.  HZ
  b44_tx)
  /* spin_unlock(&bp->tx_lock); */
 }
 ifif( java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  bp-returnjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  b44_disable_ints(bp)
  Polling     diagnostic
  b44_init_rings
  void b44_poll_controller(struct net_device *devjava.lang.StringIndexOutOfBoundsException: Range [55, 56) out of bounds for length 55
  netif_wake_queue(bp-
 }

 spin_unlock_irqrestorevoid b pp ,u32)

 work_done = 0; java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
 if (bp->istat & ISTAT_RX(B44_FILT_ADDR ijava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  work_done +

 >&)
  spin_lock_irqsave(&bp->  int
  b44_halt
  int magicsync 
  b44_init_hw(int ;
  netif_wake_queue(memset  , 0, );
  =  ; j+java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  work_donejava.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

  ){
  napi_complete_done(  <0java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 b44_enable_ints(;
 }

  [offset  +
}

pma > = BIT  7
 ++;
 struct net_devicejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 struct
 u32 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 int handled = 0 *

(>lock

 istat =
   val

java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
  u8 pwol_mask[
  * but doesn if (!pwol_pattern
  */
 &;
 if    bp-dev_addrp,
  java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

  if ((, ,)
   netdev_info(
   /* Raw ethernet II magic packet pattern - pattern 1 */
 }

  if (napi_schedule_prep(&bp->napi)) {
   /* NOTE: These writes are posted by the readback of(,0B44_PMASK_SIZEjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 *       the ISTAT register below.
 */

 (,,
_()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

  }

:
( _)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  br32

 spin_unlock(   )
 return IRQ_RETVAL(, ,
}

static void
{kfree
 struct b44

  =  plen1)( < ;

(>)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 b44_init_rings(bp java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
 b44_init_hw(bp ;

 spin_unlock_irq>bustype){

 b44_enable_ints(bp);

>SSB_PMCSRjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
}

static static inline voidstruct*) 
{
 struct java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 int   ;
 dma_addr_tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 (flagsjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
 unsigned long flags

 len = skb->len;
 spin_lock_irqsave >[<|

 /* This is a hard error, log it. */;
 (() {
  netif_stop_queue
(" whenqueue!\"
  goto>[java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 mapping = dma_map_single(  | |)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 if
  b44_setup_wol_pcijava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

  /* Chip can't handle DMA to/from >1GB, use bounce buffer */  *  ();
 netif_stop_queue)
   dma_unmap_single  (>flagsB44_FLAG_EXTERNAL_PHY
  (>phydev

  bounce_skb = napi_disable&>napi
  if (!bounce_skb)
 goto;

 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      len)
)
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(sdev-,
 
   dev_kfree_skb_any>&)
   gotobp)
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  skb_copy_from_linear_data(return
}
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }

 entry =
  structbp (dev
 bp-  =>hw_stats

 ctrl  = (len & DESC_CTRL_LEN);
 ctrl
 if (entrystart (&>syncp
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

] ()java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
 bp-tx_errors> 

 if (bp->flags>java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
(sdev,
                       >=>;
                    ;

 entry = NEXT_TX(entryrx_over_errors>java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51

 bp-> >        >java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

 wmb 

 bw32(bp,   +
 if (bp-
(, sizeof);
 ifjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  br32(bp, B44_DMATX_PTRjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

(,>);

 if struct ha
  netif_stop_queue

ock
 (>,)

  ;

err_out:
 rc = NETDEV_TX_BUSY
returnjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}

(  *, )
{
 struct b44

 !) 
/
   * device is  val |= RXCONFIG_PROMISC  bw32(bp, java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9
  
   if ((dev->flags ount(dev) > B44_MCAST_TABLE_SIZE))
  return  else
 }

 spin_lock_irq(&  for (; i < 64; i++)
 b44_halt(  bw32(bp, B44_RXCONFIG,   val = br32         bw32(bp, B44_CAM_CTRL, }
 WRITE_ONCE(dev-{
 b44_init_rings(bp);
 b44_init_hw spin_lock_irq(&bp->lock __b44_set_rx_mode(dev) spin_unlock_irq(&bp->lock}
 spin_unlock_irq(&bp-static u32 b44_get_msglevel(struct{

  return bp->msg_enable}

 return 0static void b44_set_msglevel(struct net_device *{
bp->msg_enable = value}

/* Free up pending packets in all rx/tx rings.static void b44_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *{
 *
 * The chip has been shut down and the driver detached from
 * the networking, so no interrupts or new tx packets will
 * end up in the driver.  bp->lock is not held and we are not
 * in an interrupt context and thus may sleep.
 */

static void case SSB_BUSTYPE_SSB  strscpy(info->bus_info,   break;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

 for (i = 0; i < B44_RX_RING_SIZE; i++) {
  rp = ,,;

 >=java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
   continue   |)
  (>)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
     DMA_FROM_DEVICE
 
  rp->static (structnet_devicedev
  struct *cmdjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41

java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
   B44_TX_RING_SIZE 
  rp(>)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46

  if
   continue;
  dma_unmap_single(bp->sdev-  java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
DMA_TO_DEVICE
  dev_kfree_skb_any(      )
 
    java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

/* Initialize tx/rx rings for packet processing.
 *
 * The chip has been shut down and the driver detached from
 * the networking, so no interrupts or new tx packets will
 * end up in the driver.
 */

c>=>  java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
{
 int i;

 b44_free_rings(bp);

 memset(bp->rx_ring,  >. =bp-flags  
 memset:;

  ifcmd-. = AUTONEG_ENABLE)
  dma_sync_single_for_device(bp->sdev->dma_dev, bp->rx_ring_dma,
 DMA_TABLE_BYTES)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

)
    )
        

> ;
 bp, 
   breakjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 }
}

/*
 * Must not be invoked with interrupt sources disabled and
 * the hardware shutdown down.
 */

void b
{
 kfree  ;
 bp->rx_buffers flagsjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
(>java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 bp->tx_buffers = NULL  = dev- )
 if (bp- (>);
  if (bp->flags & B44_FLAG_RX_RING_HACK) {
   return;
 
   kfree
 
   dma_free_coherent((,
  >advertising
  bp-> /* We do not support gigabit. */
  bp-flags;
 }
 if (bp-( |
 >)
   java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 18
       >duplex&
 (>);

   dma_free_coherent(
 (lock
  bp->tx_ring >. )
  f&~ java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 }
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31

/*
 * Must not be invoked with interrupt sources disabled and
 * the hardware shutdown down.  Can sleep.
 */

 (b44  )
{
 int size;

sizeof)
 bp-> bp->flagsjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 if (!bp->rx_buffers)
  goto out_err  &)

sizeof )java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
>kzalloc)
 >& )
 speedjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

 >;
 bp->rx_ringjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      &
 )
  /* Allocation may have failed due to dma_alloc_coherent
   insisting on use of GFP_DMA, which is more restrictive
   than necessary...  */

 return
  dma_addr_t

  rx_ring = kzalloc (*
  if        *java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
   java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

dma_devjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
      ,
          DMA_BIDIRECTIONAL)}

  if (dma_mapping_error(bp->sdev->dma_dev
+ (0 
   kfree(rx_ring) structering

  }

> ;
  ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }

 bp->>   -
 > 
 if (
java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
   bp->tx_pending = ering-
     than b44_init_rings(bp);
  struct  netif_wake_queue(bp->dev);
  dma_addr_t tx_ring_dma b44_enable_ints(bp);

  tx_ring = }
  if
   gotostatic void b44_get_pauseparam(struct 

  tx_ring_dma = dma_map_single(bp->sdev-
           epause->autoneg =
          DMA_TO_DEVICE epause->rx_pause =  (bp->flags epause->tx_pause =  (bp->flags }

  if (dma_mapping_error    struct ethtool_pauseparam *
   tx_ring_dma
   spin_lock_irq(&bp->lock if (epause->autoneg)
   goto else
  } if (epause->rx_pause  bp->flags else

  bp-  bp->flags else
  bp->tx_ring_dma = if (netif_running(dev))   if (bp->flags    b44_halt(bp);
  bp->flags   __b44_set_flow_ctrl(bp  }
 }

 return 0;

out_err:
 b44_free_consistent(bp}
 return -ENOMEMstatic void b44_get_strings(struct net_device *dev, u32{
}

/* bp->lock is held. */
static void java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2
{{
 switch (sset)  case ETH_SS_STATS:

 bw32  return -EOPNOTSUPP;
 for }
  br32java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 for (reg{
  struct b44 *bp = netdev_priv( struct b44_hw_stats *hwstat = &bp- u64 *data_src, *data_dst unsigned int start;
}
 b44_stats_update(bp);
/* bp->lock is held. */
static void do {
{
 struct ssb_device *sdev =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 bool was_enabled;

 was_enabled = static void b44_get_wol(struct net_device *dev, {

 ssb_device_enable(bp- wol->supported = WAKE_MAGIC if (bp->flags & B44_FLAG_WOL_ENABLE  wol->wolopts =  else
 ssb_pcicore_dev_irqvecs_enable(&sdev->bus->pcicore,}

 if (static int b44_set_wol(struct net_device *dev
  bw32(
  bw32(bp if (wol->wolopts & WAKE_MAGIC  bp->flags |= else
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  bw32}

static const struct ethtool_ops b44_ethtool_ops .get_drvinfo  = b44_get_drvinfo .nway_reset  = b44_nway_reset,
   b44_wait_bit(bp .get_ringparam  = b44_get_ringparam .set_ringparam  = b44_set_ringparam,
         100, .get_msglevel  = b44_get_msglevel .set_msglevel  = b44_set_msglevel, .get_strings  = b44_get_strings,
  }
  bw32(bp .set_link_ksettings = b44_set_link_ksettings,
  bp->rx_prod
 }

 b44_clear_stats(bp) struct b44 *bp  int err = -

 /*
 * Don't enable PHY if we are doing a partial reset
 * we are probably going to power down
 */

 if ( } else {
  return;

 switch (sdev-out:
 case }
  bw32(bp,static int b44_get_invariants(struct b44 *bp)
  bp->dma_offset = ssb_dma_translation(sdev);
      if (sdev->bus->bustype == SSB_BUSTYPE_SSB     instance > 1) {
       & MDIO_CTRL_MAXF_MASK  bp->phy_addr = sdev->bus->sprom. } else {
  break;
 case SSB_BUSTYPE_PCI:
  bw32(bp, B44_MDIO_CTRL, /* Some ROMs have buggy PHY addresses with the high
     (0x0d & MDIO_CTRL_MAXF_MASK)));
break;
case SSB_BUSTYPE_PCMCIA:
case SSB_BUSTYPE_SDIO:
WARN_ON(1); /* A device with this bus does not exist. */

  break;
 }

 br32(bp, B44_MDIO_CTRL);

 if (!(br32(bp, B44_DEVCTRL) & DEVCTRL_IPP)) {
   if ((&bp->dev_addr[0)){
  br32 pr_errInvalid MAC n);
  bp->   -;
 } else {
  u32 val = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  if /* XXX - really required?
bw32(bp, B44_DEVCTRL, (val & ~DEVCTRL_EPR));
br32(bp, B44_DEVCTRL);
udelay(100);
}
bp->flags &= ~B44_FLAG_EXTERNAL_PHY;
}
}

/* bp->lock is held. */

static void b44_halt(struct b44 *bp)
{
 b44_disable_ints(bp);
 /* reset PHY */
 b44_phy_reset(bp);
 /* power down PHY */
netdev_info(>dev poweringn"
 bw32(bp, B44_MAC_CTRL.  = b44_openjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Range [56, 57) out of bounds for length 56
  *  * o_validate_addr = eth_validate_addr,
 if  .ndo_tx_timeout  = b44_tx_timeout,
#ifdef CONFIG_NET_POLL_CONTROLLER
 else
  b44_chip_reset};
}

/* bp->lock is held. */
static  struct b44 *bp = netdev_priv(dev);
{
 bw32
 if (BUG_ON(!phydev);
  u32 val;

  __b44_cam_write= true;
  val = }
  bw32(bp, B44_CAM_CTRL
 }
}

static b44_set_mac_addrstruct dev *
{
  bp(dev
 struct sockaddr *  =;
 u32 > & B44_FLAG_FULL_DUPLEX

 if (netif_running(dev   bp- ))java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  return -EBUSY

 if
  () {

 eth_hw_addr_set(dev, addr->sa_data);

 (>);

 val = br32(bp, B44_RXCONFIG)ifbp- & )
 if ! &))
  __b44_set_mac_addr(bpjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
 bw32,B44_TX_CTRLval)
 spin_unlock_irq(&bp-  phy_print_statusphydev;

 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}

/* Called at device open time to get the chip ready for
 * packet processing.  Invoked with bp->lock held.
 */

static __b44_set_rx_modestruct *);
static void b44_init_hw(struct b44 *bp, int reset_kind)
{
 u32 val;

 b44_chip_reset(bp, B44_CHIP_RESET_FULL);
 if (reset_kind ==  struct phy_devicephydev
  ();
  b44_setup_phystructssb_sprom * = &dev->;
 }

 /* Enable CRC32, set proper LED modes and power on PHY */
bw32, B44_MAC_CTRL MAC_CTRL_CRC32_ENAB );
 bw32(  (!mii_bus) {

 /* This sets the MAC address too.  */
 __b44_set_rx_mode(bp->dev);

 /* MTU + eth header + possible VLAN tag + struct rx_header */
 bw32(bp, B44_RXMAXLEN, bp->java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 16
 bw32(bp, B44_TXMAXLEN

 bw32(bp, B44_TX_WMARK, m>privjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  bw32(bp, B44_DMARX_CTRL  >;
  >=1>)
 } else {
( ,);
  bw32(bp, B44_DMATX_ADDR, bp->tx_ring_dma + bp->dma_offset);
  bw32>  ;
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  bw32(bp((>,failedn)

  bw32}


bw32,)
 }

 val = br32(bp, B44_ENET_CTRL)
dsdev-

   >;


static int  (,sizeof) ,fixed-0
{
 struct b44 *bp = netdev_priv(dev);
 int err;

 err = b44_alloc_consistent(bp, GFP_KERNEL);
if)
  goto out;

(>)

 b44_init_rings(bp
 b44_init_hw(bp, (bp-  ,

 b44_check_phy(bp);

 sdev-couldn
 if (>)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  napi_disable(&bp-
 (,)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  b44_free_rings(bp);
  b44_free_consistent(bp);
  goto out;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
 bp->timerjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 add_timer java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10

 b44_enable_ints(

 if (bp->flags  (;
  phy_start(dev-err_out:

 netif_start_queue(dev
out:
;
}


/*
 * Polling receive - used by netconsole and other diagnostic tools
 * to allow network i/o with interrupts disabled.
 */

staticmdiobus_unregisterjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

 disable_irq(  *,
 b44_interrupt(dev->irq, dev);
 enable_irq(dev->irq);
}
#endif  *

static void bwfilter_table
{
 u32 i;
 u32 *pattern)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

 for (i = 0SET_NETDEV_DEV >dev
  bw32/
  bw32(bp> =0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

  (u8 ,*,
        int offset)
{
 int magicsync
  (>);
 int ethaddr_bytesbp-syncp

 memset(> B44_DEF_RX_RING_PENDING
 j    ;+
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  len+> java.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

  j;)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  if ((   n;
   ethaddr_bytes = ETH_ALEN;
 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
   ethaddr_bytes (dma_dev3)
  if if ()
   (dev
   ;java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 38
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     ,)
;
   len++;
  }
 }
   1
}

/* Setup magic packet patterns in the b44 WOL
 * pattern matching filter.
 */

  (  *)
{

u32
 phy_id_mask;
 ;
 u8 pwol_maskjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55

 pwol_pattern = kzalloc(B44_PATTERN_SIZE
 if (!pwol_pattern)
  return;

 /* Ipv4 magic packet pattern - pattern 0.*/
 memset( dev_err(sdev-Cannot \)
 bp-dev_addr,,
      B44_ETHIPV4UDP_HLEN);


 bwfilter_table;

 /* Raw ethernet II magic packet pattern - pattern 1 */)
 memsetjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 memsetb;
 plen1 = b44_magic_pattern(bp-
 )

 bwfilter_table( errjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
         B44_PATTERN_BASE 
 bwfilter_table(bp,  if (bp->flags & B44_FLAG_EXTERNAL_PHY
         B44_PMASK_BASE + B44_PMASK_SIZE (){

 /* Ipv6 magic packet pattern - pattern 2 */
( B44_PATTERN_SIZE
 memset
 plen2 = b44_magic_pattern
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 bwfilter_table(bp, pwol_patternjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
         B44_PATTERN_BASE u()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 bwfilter_table(
       + )

 kfree(pwol_pattern);

 /* set these pattern's lengths: one less than each real length */
 val = plen0
 bw32

/
 val = br32(bp, B44_DEVCTRL
    ();

java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

#ifdef ()java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
static void netif_napi_del(&bp->napi)
{
 ;

 if (bp->}

 (ssb_device  )
  pci_write_config_word
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
#else
static inline voidjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#endif /* CONFIG_B44_PCI */

static void b44_setup_wol(struct b44 *bp)
{
  ;

 bw32

 if (
(>,dev
bp,)

  val = bp->dev->dev_addr)
   bp->dev->
   bp-( );
 ;
( )

 static (  *)
   bp-{
( , )java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

  val =  sdev-;
  bw32java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

 }  0
  
 }
 b44_setup_wol_pci(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}

static int b44_close(  * As a shared interrupt,  * able to check the interrupt   * powered back on (b44_init_hw
{
 struct{

 netif_stop_queue(dev);

 if (bp->()
(>)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24

 napi_disable(;

 timer_delete_sync(&bp- ()

 spin_lock_irq(&bp-

 b44_halt(bpjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(;
 netif_carrier_off(dev  ,

 spin_unlock_irq(&bp- java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24

 free_irq(dev-

(flagsjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  b44_init_hw(bp, java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  b44_setup_wol(bperr
 }

 b44_free_consistent(bp);

 return 0;
}

static
    *
{
 struct b44    =)
 struct ;
 unsigned int start;java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57

 do {
  start = u64_stats_fetch_begin(&hwstat->syncp);

    stats
  nstat-e  (java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  nstat->tx_packets = hwstat-java.lang.StringIndexOutOfBoundsException: Range [29, 30) out of bounds for length 1
  nstat->rx_bytes
  (;
  nstat->tx_errors  = (hwstat->
         hwstat->tx_oversize_pkts +
         hwstat->tx_underruns +
         hwstat->tx_excessive_cols +
         hwstat->tx_late_cols);
  nstat->multicast  = hwstat->rx_multicast_pkts;
  nstat->collisions = hwstat->tx_total_cols;

  nstat->rx_length_errors = (hwstat->rx_oversize_pkts +
        hwstat->rx_undersize);
  nstat->rx_over_errors   = hwstat->rx_missed_pkts;
  nstat->rx_frame_errors  = hwstat->rx_align_errs;
  nstat->rx_crc_errors    = hwstat->rx_crc_errs;
  nstat->rx_errors        = (hwstat->rx_jabber_pkts +
        hwstat->rx_oversize_pkts +
        hwstat->rx_missed_pkts +
        hwstat->rx_crc_align_errs +
        hwstat->rx_undersize +
        hwstat->rx_crc_errs +
        hwstat->rx_align_errs +
        hwstat->rx_symbol_errs);

  nstat->tx_aborted_errors = hwstat->tx_underruns;
#if 0
  /* Carrier lost counter seems to be broken for some devices */
  nstat->tx_carrier_errors = hwstat->tx_carrier_lost;
#endif
 } while (u64_stats_fetch_retry(&hwstat->syncp, start));

}

static int __b44_load_mcast(struct b44 *bp, struct net_device *dev)
{
 struct netdev_hw_addr *ha;
 int i, num_ents;

 num_ents = min_t(int, netdev_mc_count(dev), B44_MCAST_TABLE_SIZE);
 i = 0;
 netdev_for_each_mc_addr(ha, dev) {
  if (i == num_ents)
   break;
  __b44_cam_write(bp, ha->addr, i++ + 1);
 }
 return i+1;
}

static void __b44_set_rx_mode(struct net_device *dev)
{
 struct b44 *bp = netdev_priv(dev);
 u32 val;

 val = br32(bp, B44_RXCONFIG);
 val &= ~(RXCONFIG_PROMISC | RXCONFIG_ALLMULTI);
 if ((dev->flags & IFF_PROMISC) || (val & RXCONFIG_CAM_ABSENT)) {
  val |= RXCONFIG_PROMISC;
  bw32(bp, B44_RXCONFIG, val);
 } else {
  unsigned char zero[6] = {0, 0, 0, 0, 0, 0};
  int i = 1;

  __b44_set_mac_addr(bp);

  if ((dev->flags & IFF_ALLMULTI) ||
      (netdev_mc_count(dev) > B44_MCAST_TABLE_SIZE))
   val |= RXCONFIG_ALLMULTI;
  else
   i = __b44_load_mcast(bp, dev);

  for (; i < 64; i++)
   __b44_cam_write(bp, zero, i);

  bw32(bp, B44_RXCONFIG, val);
  val = br32(bp, B44_CAM_CTRL);
         bw32(bp, B44_CAM_CTRL, val | CAM_CTRL_ENABLE);
 }
}

static void b44_set_rx_mode(struct net_device *dev)
{
 struct b44 *bp = netdev_priv(dev);

 spin_lock_irq(&bp->lock);
 __b44_set_rx_mode(dev);
 spin_unlock_irq(&bp->lock);
}

static u32 b44_get_msglevel(struct net_device *dev)
{
 struct b44 *bp = netdev_priv(dev);
 return bp->msg_enable;
}

static void b44_set_msglevel(struct net_device *dev, u32 value)
{
 struct b44 *bp = netdev_priv(dev);
 bp->msg_enable = value;
}

static void b44_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
{
 struct b44 *bp = netdev_priv(dev);
 struct ssb_bus *bus = bp->sdev->bus;

 strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
 switch (bus->bustype) {
 case SSB_BUSTYPE_PCI:
  strscpy(info->bus_info, pci_name(bus->host_pci), sizeof(info->bus_info));
  break;
 case SSB_BUSTYPE_SSB:
  strscpy(info->bus_info, "SSB"sizeof(info->bus_info));
  break;
 case SSB_BUSTYPE_PCMCIA:
 case SSB_BUSTYPE_SDIO:
  WARN_ON(1); /* A device with this bus does not exist. */
  break;
 }
}

static int b44_nway_reset(struct net_device *dev)
{
 struct b44 *bp = netdev_priv(dev);
 u32 bmcr;
 int r;

 spin_lock_irq(&bp->lock);
 b44_readphy(bp, MII_BMCR, &bmcr);
 b44_readphy(bp, MII_BMCR, &bmcr);
 r = -EINVAL;
 if (bmcr & BMCR_ANENABLE)
  r = b44_writephy(bp, MII_BMCR,
     bmcr | BMCR_ANRESTART);
 spin_unlock_irq(&bp->lock);

 return r;
}

static int b44_get_link_ksettings(struct net_device *dev,
      struct ethtool_link_ksettings *cmd)
{
 struct b44 *bp = netdev_priv(dev);
 u32 supported, advertising;

 if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
  BUG_ON(!dev->phydev);
  phy_ethtool_ksettings_get(dev->phydev, cmd);

  return 0;
 }

 supported = (SUPPORTED_Autoneg);
 supported |= (SUPPORTED_100baseT_Half |
        SUPPORTED_100baseT_Full |
        SUPPORTED_10baseT_Half |
        SUPPORTED_10baseT_Full |
        SUPPORTED_MII);

 advertising = 0;
 if (bp->flags & B44_FLAG_ADV_10HALF)
  advertising |= ADVERTISED_10baseT_Half;
 if (bp->flags & B44_FLAG_ADV_10FULL)
  advertising |= ADVERTISED_10baseT_Full;
 if (bp->flags & B44_FLAG_ADV_100HALF)
  advertising |= ADVERTISED_100baseT_Half;
 if (bp->flags & B44_FLAG_ADV_100FULL)
  advertising |= ADVERTISED_100baseT_Full;
 advertising |= ADVERTISED_Pause | ADVERTISED_Asym_Pause;
 cmd->base.speed = (bp->flags & B44_FLAG_100_BASE_T) ?
  SPEED_100 : SPEED_10;
 cmd->base.duplex = (bp->flags & B44_FLAG_FULL_DUPLEX) ?
  DUPLEX_FULL : DUPLEX_HALF;
 cmd->base.port = 0;
 cmd->base.phy_address = bp->phy_addr;
 cmd->base.autoneg = (bp->flags & B44_FLAG_FORCE_LINK) ?
  AUTONEG_DISABLE : AUTONEG_ENABLE;
 if (cmd->base.autoneg == AUTONEG_ENABLE)
  advertising |= ADVERTISED_Autoneg;

 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
      supported);
 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
      advertising);

 if (!netif_running(dev)){
  cmd->base.speed = 0;
  cmd->base.duplex = 0xff;
 }

 return 0;
}

static int b44_set_link_ksettings(struct net_device *dev,
      const struct ethtool_link_ksettings *cmd)
{
 struct b44 *bp = netdev_priv(dev);
 u32 speed;
 int ret;
 u32 advertising;

 if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
  BUG_ON(!dev->phydev);
  spin_lock_irq(&bp->lock);
  if (netif_running(dev))
   b44_setup_phy(bp);

  ret = phy_ethtool_ksettings_set(dev->phydev, cmd);

  spin_unlock_irq(&bp->lock);

  return ret;
 }

 speed = cmd->base.speed;

 ethtool_convert_link_mode_to_legacy_u32(&advertising,
      cmd->link_modes.advertising);

 /* We do not support gigabit. */
 if (cmd->base.autoneg == AUTONEG_ENABLE) {
  if (advertising &
      (ADVERTISED_1000baseT_Half |
       ADVERTISED_1000baseT_Full))
   return -EINVAL;
 } else if ((speed != SPEED_100 &&
      speed != SPEED_10) ||
     (cmd->base.duplex != DUPLEX_HALF &&
      cmd->base.duplex != DUPLEX_FULL)) {
   return -EINVAL;
 }

 spin_lock_irq(&bp->lock);

 if (cmd->base.autoneg == AUTONEG_ENABLE) {
  bp->flags &= ~(B44_FLAG_FORCE_LINK |
          B44_FLAG_100_BASE_T |
          B44_FLAG_FULL_DUPLEX |
          B44_FLAG_ADV_10HALF |
          B44_FLAG_ADV_10FULL |
          B44_FLAG_ADV_100HALF |
          B44_FLAG_ADV_100FULL);
  if (advertising == 0) {
   bp->flags |= (B44_FLAG_ADV_10HALF |
          B44_FLAG_ADV_10FULL |
          B44_FLAG_ADV_100HALF |
          B44_FLAG_ADV_100FULL);
  } else {
   if (advertising & ADVERTISED_10baseT_Half)
    bp->flags |= B44_FLAG_ADV_10HALF;
   if (advertising & ADVERTISED_10baseT_Full)
    bp->flags |= B44_FLAG_ADV_10FULL;
   if (advertising & ADVERTISED_100baseT_Half)
    bp->flags |= B44_FLAG_ADV_100HALF;
   if (advertising & ADVERTISED_100baseT_Full)
    bp->flags |= B44_FLAG_ADV_100FULL;
  }
 } else {
  bp->flags |= B44_FLAG_FORCE_LINK;
  bp->flags &= ~(B44_FLAG_100_BASE_T | B44_FLAG_FULL_DUPLEX);
  if (speed == SPEED_100)
   bp->flags |= B44_FLAG_100_BASE_T;
  if (cmd->base.duplex == DUPLEX_FULL)
   bp->flags |= B44_FLAG_FULL_DUPLEX;
 }

 if (netif_running(dev))
  b44_setup_phy(bp);

 spin_unlock_irq(&bp->lock);

 return 0;
}

static void b44_get_ringparam(struct net_device *dev,
         struct ethtool_ringparam *ering,
         struct kernel_ethtool_ringparam *kernel_ering,
         struct netlink_ext_ack *extack)
{
 struct b44 *bp = netdev_priv(dev);

 ering->rx_max_pending = B44_RX_RING_SIZE - 1;
 ering->rx_pending = bp->rx_pending;

 /* XXX ethtool lacks a tx_max_pending, oops... */
}

static int b44_set_ringparam(struct net_device *dev,
        struct ethtool_ringparam *ering,
        struct kernel_ethtool_ringparam *kernel_ering,
        struct netlink_ext_ack *extack)
{
 struct b44 *bp = netdev_priv(dev);

 if ((ering->rx_pending > B44_RX_RING_SIZE - 1) ||
     (ering->rx_mini_pending != 0) ||
     (ering->rx_jumbo_pending != 0) ||
     (ering->tx_pending > B44_TX_RING_SIZE - 1))
  return -EINVAL;

 spin_lock_irq(&bp->lock);

 bp->rx_pending = ering->rx_pending;
 bp->tx_pending = ering->tx_pending;

 b44_halt(bp);
 b44_init_rings(bp);
 b44_init_hw(bp, B44_FULL_RESET);
 netif_wake_queue(bp->dev);
 spin_unlock_irq(&bp->lock);

 b44_enable_ints(bp);

 return 0;
}

static void b44_get_pauseparam(struct net_device *dev,
    struct ethtool_pauseparam *epause)
{
 struct b44 *bp = netdev_priv(dev);

 epause->autoneg =
  (bp->flags & B44_FLAG_PAUSE_AUTO) != 0;
 epause->rx_pause =
  (bp->flags & B44_FLAG_RX_PAUSE) != 0;
 epause->tx_pause =
  (bp->flags & B44_FLAG_TX_PAUSE) != 0;
}

static int b44_set_pauseparam(struct net_device *dev,
    struct ethtool_pauseparam *epause)
{
 struct b44 *bp = netdev_priv(dev);

 spin_lock_irq(&bp->lock);
 if (epause->autoneg)
  bp->flags |= B44_FLAG_PAUSE_AUTO;
 else
  bp->flags &= ~B44_FLAG_PAUSE_AUTO;
 if (epause->rx_pause)
  bp->flags |= B44_FLAG_RX_PAUSE;
 else
  bp->flags &= ~B44_FLAG_RX_PAUSE;
 if (epause->tx_pause)
  bp->flags |= B44_FLAG_TX_PAUSE;
 else
  bp->flags &= ~B44_FLAG_TX_PAUSE;
 if (netif_running(dev)) {
  if (bp->flags & B44_FLAG_PAUSE_AUTO) {
   b44_halt(bp);
   b44_init_rings(bp);
   b44_init_hw(bp, B44_FULL_RESET);
  } else {
   __b44_set_flow_ctrl(bp, bp->flags);
  }
 }
 spin_unlock_irq(&bp->lock);

 b44_enable_ints(bp);

 return 0;
}

static void b44_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
 switch(stringset) {
 case ETH_SS_STATS:
  memcpy(data, *b44_gstrings, sizeof(b44_gstrings));
  break;
 }
}

static int b44_get_sset_count(struct net_device *dev, int sset)
{
 switch (sset) {
 case ETH_SS_STATS:
  return ARRAY_SIZE(b44_gstrings);
 default:
  return -EOPNOTSUPP;
 }
}

static void b44_get_ethtool_stats(struct net_device *dev,
      struct ethtool_stats *stats, u64 *data)
{
 struct b44 *bp = netdev_priv(dev);
 struct b44_hw_stats *hwstat = &bp->hw_stats;
 u64 *data_src, *data_dst;
 unsigned int start;
 u32 i;

 spin_lock_irq(&bp->lock);
 b44_stats_update(bp);
 spin_unlock_irq(&bp->lock);

 do {
  data_src = &hwstat->tx_good_octets;
  data_dst = data;
  start = u64_stats_fetch_begin(&hwstat->syncp);

  for (i = 0; i < ARRAY_SIZE(b44_gstrings); i++)
   *data_dst++ = *data_src++;

 } while (u64_stats_fetch_retry(&hwstat->syncp, start));
}

static void b44_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
 struct b44 *bp = netdev_priv(dev);

 wol->supported = WAKE_MAGIC;
 if (bp->flags & B44_FLAG_WOL_ENABLE)
  wol->wolopts = WAKE_MAGIC;
 else
  wol->wolopts = 0;
 memset(&wol->sopass, 0, sizeof(wol->sopass));
}

static int b44_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
 struct b44 *bp = netdev_priv(dev);

 spin_lock_irq(&bp->lock);
 if (wol->wolopts & WAKE_MAGIC)
  bp->flags |= B44_FLAG_WOL_ENABLE;
 else
  bp->flags &= ~B44_FLAG_WOL_ENABLE;
 spin_unlock_irq(&bp->lock);

 device_set_wakeup_enable(bp->sdev->dev, wol->wolopts & WAKE_MAGIC);
 return 0;
}

static const struct ethtool_ops b44_ethtool_ops = {
 .get_drvinfo  = b44_get_drvinfo,
 .nway_reset  = b44_nway_reset,
 .get_link  = ethtool_op_get_link,
 .get_wol  = b44_get_wol,
 .set_wol  = b44_set_wol,
 .get_ringparam  = b44_get_ringparam,
 .set_ringparam  = b44_set_ringparam,
 .get_pauseparam  = b44_get_pauseparam,
 .set_pauseparam  = b44_set_pauseparam,
 .get_msglevel  = b44_get_msglevel,
 .set_msglevel  = b44_set_msglevel,
 .get_strings  = b44_get_strings,
 .get_sset_count  = b44_get_sset_count,
 .get_ethtool_stats = b44_get_ethtool_stats,
 .get_link_ksettings = b44_get_link_ksettings,
 .set_link_ksettings = b44_set_link_ksettings,
};

static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
 struct b44 *bp = netdev_priv(dev);
 int err = -EINVAL;

 if (!netif_running(dev))
  goto out;

 spin_lock_irq(&bp->lock);
 if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
  BUG_ON(!dev->phydev);
  err = phy_mii_ioctl(dev->phydev, ifr, cmd);
 } else {
  err = generic_mii_ioctl(&bp->mii_if, if_mii(ifr), cmd, NULL);
 }
 spin_unlock_irq(&bp->lock);
out:
 return err;
}

static int b44_get_invariants(struct b44 *bp)
{
 struct ssb_device *sdev = bp->sdev;
 int err = 0;
 u8 *addr;

 bp->dma_offset = ssb_dma_translation(sdev);

 if (sdev->bus->bustype == SSB_BUSTYPE_SSB &&
     instance > 1) {
  addr = sdev->bus->sprom.et1mac;
  bp->phy_addr = sdev->bus->sprom.et1phyaddr;
 } else {
  addr = sdev->bus->sprom.et0mac;
  bp->phy_addr = sdev->bus->sprom.et0phyaddr;
 }
 /* Some ROMs have buggy PHY addresses with the high
 * bits set (sign extension?). Truncate them to a
 * valid PHY address. */

 bp->phy_addr &= 0x1F;

 eth_hw_addr_set(bp->dev, addr);

 if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){
  pr_err("Invalid MAC address found in EEPROM\n");
  return -EINVAL;
 }

 bp->imask = IMASK_DEF;

 /* XXX - really required?
   bp->flags |= B44_FLAG_BUGGY_TXPTR;
*/


 if (bp->sdev->id.revision >= 7)
  bp->flags |= B44_FLAG_B0_ANDLATER;

 return err;
}

static const struct net_device_ops b44_netdev_ops = {
 .ndo_open  = b44_open,
 .ndo_stop  = b44_close,
 .ndo_start_xmit  = b44_start_xmit,
 .ndo_get_stats64 = b44_get_stats64,
 .ndo_set_rx_mode = b44_set_rx_mode,
 .ndo_set_mac_address = b44_set_mac_addr,
 .ndo_validate_addr = eth_validate_addr,
 .ndo_eth_ioctl  = b44_ioctl,
 .ndo_tx_timeout  = b44_tx_timeout,
 .ndo_change_mtu  = b44_change_mtu,
#ifdef CONFIG_NET_POLL_CONTROLLER
 .ndo_poll_controller = b44_poll_controller,
#endif
};

static void b44_adjust_link(struct net_device *dev)
{
 struct b44 *bp = netdev_priv(dev);
 struct phy_device *phydev = dev->phydev;
 bool status_changed = false;

 BUG_ON(!phydev);

 if (bp->old_link != phydev->link) {
  status_changed = true;
  bp->old_link = phydev->link;
 }

 /* reflect duplex change */
 if (phydev->link) {
  if ((phydev->duplex == DUPLEX_HALF) &&
      (bp->flags & B44_FLAG_FULL_DUPLEX)) {
   status_changed = true;
   bp->flags &= ~B44_FLAG_FULL_DUPLEX;
  } else if ((phydev->duplex == DUPLEX_FULL) &&
      !(bp->flags & B44_FLAG_FULL_DUPLEX)) {
   status_changed = true;
   bp->flags |= B44_FLAG_FULL_DUPLEX;
  }
 }

 if (status_changed) {
  u32 val = br32(bp, B44_TX_CTRL);
  if (bp->flags & B44_FLAG_FULL_DUPLEX)
   val |= TX_CTRL_DUPLEX;
  else
   val &= ~TX_CTRL_DUPLEX;
  bw32(bp, B44_TX_CTRL, val);
  phy_print_status(phydev);
 }
}

static int b44_register_phy_one(struct b44 *bp)
{
 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 struct mii_bus *mii_bus;
 struct ssb_device *sdev = bp->sdev;
 struct phy_device *phydev;
 char bus_id[MII_BUS_ID_SIZE + 3];
 struct ssb_sprom *sprom = &sdev->bus->sprom;
 int err;

 mii_bus = mdiobus_alloc();
 if (!mii_bus) {
  dev_err(sdev->dev, "mdiobus_alloc() failed\n");
  err = -ENOMEM;
  goto err_out;
 }

 mii_bus->priv = bp;
 mii_bus->read = b44_mdio_read_phylib;
 mii_bus->write = b44_mdio_write_phylib;
 mii_bus->name = "b44_eth_mii";
 mii_bus->parent = sdev->dev;
 mii_bus->phy_mask = ~(1 << bp->phy_addr);
 snprintf(mii_bus->id, MII_BUS_ID_SIZE, "%x", instance);

 bp->mii_bus = mii_bus;

 err = mdiobus_register(mii_bus);
 if (err) {
  dev_err(sdev->dev, "failed to register MII bus\n");
  goto err_out_mdiobus;
 }

 if (!mdiobus_is_registered_device(bp->mii_bus, bp->phy_addr) &&
     (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {

  dev_info(sdev->dev,
    "could not find PHY at %i, use fixed one\n",
    bp->phy_addr);

  bp->phy_addr = 0;
  snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, "fixed-0",
    bp->phy_addr);
 } else {
  snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, mii_bus->id,
    bp->phy_addr);
 }

 phydev = phy_connect(bp->dev, bus_id, &b44_adjust_link,
        PHY_INTERFACE_MODE_MII);
 if (IS_ERR(phydev)) {
  dev_err(sdev->dev, "could not attach PHY at %i\n",
   bp->phy_addr);
  err = PTR_ERR(phydev);
  goto err_out_mdiobus_unregister;
 }

 /* mask with MAC supported features */
 linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask);
 linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, mask);
 linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, mask);
 linkmode_set_bit(ETHTOOL_LINK_MODE_MII_BIT, mask);
 linkmode_and(phydev->supported, phydev->supported, mask);
 linkmode_copy(phydev->advertising, phydev->supported);

 bp->old_link = 0;
 bp->phy_addr = phydev->mdio.addr;

 phy_attached_info(phydev);

 return 0;

err_out_mdiobus_unregister:
 mdiobus_unregister(mii_bus);

err_out_mdiobus:
 mdiobus_free(mii_bus);

err_out:
 return err;
}

static void b44_unregister_phy_one(struct b44 *bp)
{
 struct net_device *dev = bp->dev;
 struct mii_bus *mii_bus = bp->mii_bus;

 phy_disconnect(dev->phydev);
 mdiobus_unregister(mii_bus);
 mdiobus_free(mii_bus);
}

static int b44_init_one(struct ssb_device *sdev,
   const struct ssb_device_id *ent)
{
 struct net_device *dev;
 struct b44 *bp;
 int err;

 instance++;

 dev = alloc_etherdev(sizeof(*bp));
 if (!dev) {
  err = -ENOMEM;
  goto out;
 }

 SET_NETDEV_DEV(dev, sdev->dev);

 /* No interesting netdevice features in this card... */
 dev->features |= 0;

 bp = netdev_priv(dev);
 bp->sdev = sdev;
 bp->dev = dev;
 bp->force_copybreak = 0;

 bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);

 spin_lock_init(&bp->lock);
 u64_stats_init(&bp->hw_stats.syncp);

 bp->rx_pending = B44_DEF_RX_RING_PENDING;
 bp->tx_pending = B44_DEF_TX_RING_PENDING;

 dev->netdev_ops = &b44_netdev_ops;
 netif_napi_add(dev, &bp->napi, b44_poll);
 dev->watchdog_timeo = B44_TX_TIMEOUT;
 dev->min_mtu = B44_MIN_MTU;
 dev->max_mtu = B44_MAX_MTU;
 dev->irq = sdev->irq;
 dev->ethtool_ops = &b44_ethtool_ops;

 err = ssb_bus_powerup(sdev->bus, 0);
 if (err) {
  dev_err(sdev->dev,
   "Failed to powerup the bus\n");
  goto err_out_free_dev;
 }

 err = dma_set_mask_and_coherent(sdev->dma_dev, DMA_BIT_MASK(30));
 if (err) {
  dev_err(sdev->dev,
   "Required 30BIT DMA mask unsupported by the system\n");
  goto err_out_powerdown;
 }

 err = b44_get_invariants(bp);
 if (err) {
  dev_err(sdev->dev,
   "Problem fetching invariants of chip, aborting\n");
  goto err_out_powerdown;
 }

 if (bp->phy_addr == B44_PHY_ADDR_NO_PHY) {
  dev_err(sdev->dev, "No PHY present on this MAC, aborting\n");
  err = -ENODEV;
  goto err_out_powerdown;
 }

 bp->mii_if.dev = dev;
 bp->mii_if.mdio_read = b44_mdio_read_mii;
 bp->mii_if.mdio_write = b44_mdio_write_mii;
 bp->mii_if.phy_id = bp->phy_addr;
 bp->mii_if.phy_id_mask = 0x1f;
 bp->mii_if.reg_num_mask = 0x1f;

 /* By default, advertise all speed/duplex settings. */
 bp->flags |= (B44_FLAG_ADV_10HALF | B44_FLAG_ADV_10FULL |
        B44_FLAG_ADV_100HALF | B44_FLAG_ADV_100FULL);

 /* By default, auto-negotiate PAUSE. */
 bp->flags |= B44_FLAG_PAUSE_AUTO;

 err = register_netdev(dev);
 if (err) {
  dev_err(sdev->dev, "Cannot register net device, aborting\n");
  goto err_out_powerdown;
 }

 netif_carrier_off(dev);

 ssb_set_drvdata(sdev, dev);

 /* Chip reset provides power to the b44 MAC & PCI cores, which
 * is necessary for MAC register access.
 */

 b44_chip_reset(bp, B44_CHIP_RESET_FULL);

 /* do a phy reset to test if there is an active phy */
 err = b44_phy_reset(bp);
 if (err < 0) {
  dev_err(sdev->dev, "phy reset failed\n");
  goto err_out_unregister_netdev;
 }

 if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
  err = b44_register_phy_one(bp);
  if (err) {
   dev_err(sdev->dev, "Cannot register PHY, aborting\n");
   goto err_out_unregister_netdev;
  }
 }

 device_set_wakeup_capable(sdev->dev, true);
 netdev_info(dev, "%s %pM\n", DRV_DESCRIPTION, dev->dev_addr);

 return 0;

err_out_unregister_netdev:
 unregister_netdev(dev);
err_out_powerdown:
 ssb_bus_may_powerdown(sdev->bus);

err_out_free_dev:
 netif_napi_del(&bp->napi);
 free_netdev(dev);

out:
 return err;
}

static void b44_remove_one(struct ssb_device *sdev)
{
 struct net_device *dev = ssb_get_drvdata(sdev);
 struct b44 *bp = netdev_priv(dev);

 unregister_netdev(dev);
 if (bp->flags & B44_FLAG_EXTERNAL_PHY)
  b44_unregister_phy_one(bp);
 ssb_device_disable(sdev, 0);
 ssb_bus_may_powerdown(sdev->bus);
 netif_napi_del(&bp->napi);
 free_netdev(dev);
 ssb_pcihost_set_power_state(sdev, PCI_D3hot);
 ssb_set_drvdata(sdev, NULL);
}

static int b44_suspend(struct ssb_device *sdev, pm_message_t state)
{
 struct net_device *dev = ssb_get_drvdata(sdev);
 struct b44 *bp = netdev_priv(dev);

 if (!netif_running(dev))
  return 0;

 timer_delete_sync(&bp->timer);

 spin_lock_irq(&bp->lock);

 b44_halt(bp);
 netif_carrier_off(bp->dev);
 netif_device_detach(bp->dev);
 b44_free_rings(bp);

 spin_unlock_irq(&bp->lock);

 free_irq(dev->irq, dev);
 if (bp->flags & B44_FLAG_WOL_ENABLE) {
  b44_init_hw(bp, B44_PARTIAL_RESET);
  b44_setup_wol(bp);
 }

 ssb_pcihost_set_power_state(sdev, PCI_D3hot);
 return 0;
}

static int b44_resume(struct ssb_device *sdev)
{
 struct net_device *dev = ssb_get_drvdata(sdev);
 struct b44 *bp = netdev_priv(dev);
 int rc = 0;

 rc = ssb_bus_powerup(sdev->bus, 0);
 if (rc) {
  dev_err(sdev->dev,
   "Failed to powerup the bus\n");
  return rc;
 }

 if (!netif_running(dev))
  return 0;

 spin_lock_irq(&bp->lock);
 b44_init_rings(bp);
 b44_init_hw(bp, B44_FULL_RESET);
 spin_unlock_irq(&bp->lock);

 /*
 * As a shared interrupt, the handler can be called immediately. To be
 * able to check the interrupt status the hardware must already be
 * powered back on (b44_init_hw).
 */

 rc = request_irq(dev->irq, b44_interrupt, IRQF_SHARED, dev->name, dev);
 if (rc) {
  netdev_err(dev, "request_irq failed\n");
  spin_lock_irq(&bp->lock);
  b44_halt(bp);
  b44_free_rings(bp);
  spin_unlock_irq(&bp->lock);
  return rc;
 }

 netif_device_attach(bp->dev);

 b44_enable_ints(bp);
 netif_wake_queue(dev);

 mod_timer(&bp->timer, jiffies + 1);

 return 0;
}

static struct ssb_driver b44_ssb_driver = {
 .name  = DRV_MODULE_NAME,
 .id_table = b44_ssb_tbl,
 .probe  = b44_init_one,
 .remove  = b44_remove_one,
 .suspend = b44_suspend,
 .resume  = b44_resume,
};

static inline int __init b44_pci_init(void)
{
 int err = 0;
#ifdef CONFIG_B44_PCI
 err = ssb_pcihost_register(&b44_pci_driver);
#endif
 return err;
}

static inline void b44_pci_exit(void)
{
#ifdef CONFIG_B44_PCI
 ssb_pcihost_unregister(&b44_pci_driver);
#endif
}

static int __init b44_init(void)
{
 unsigned int dma_desc_align_size = dma_get_cache_alignment();
 int err;

 /* Setup parameters for syncing RX/TX DMA descriptors */
 dma_desc_sync_size = max_t(unsigned int, dma_desc_align_size, sizeof(struct dma_desc));

 err = b44_pci_init();
 if (err)
  return err;
 err = ssb_driver_register(&b44_ssb_driver);
 if (err)
  b44_pci_exit();
 return err;
}

static void __exit b44_cleanup(void)
{
 ssb_driver_unregister(&b44_ssb_driver);
 b44_pci_exit();
}

module_init(b44_init);
module_exit(b44_cleanup);


Messung V0.5
C=98 H=89 G=93

¤ Dauer der Verarbeitung: 0.40 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






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.