root/dev/ic/rlnvar.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /*      $OpenBSD: rlnvar.h,v 1.7 2002/06/09 03:14:18 todd Exp $ */
    2 /*
    3  * David Leonard <d@openbsd.org>, 1999. Public domain.
    4  *
    5  * Proxim RangeLAN2 soft state copy.
    6  */
    7 
    8 #include <sys/timeout.h>
    9 
   10 /*
   11  * Mailboxes are used to communicate card-initiated messages
   12  * from the interrupt handler to other kernel threads.
   13  */
   14 struct rln_mbox {
   15         void *          mb_buf;         /* Message buffer */
   16         size_t          mb_len;         /* Message buffer size */
   17         size_t          mb_actlen;      /* Actual message size */
   18         u_int8_t        mb_state;       /* Mailbox state */
   19 #define RLNMBOX_VOID            0
   20 #define RLNMBOX_EMPTY           1
   21 #define RLNMBOX_FILLING         2
   22 #define RLNMBOX_FILLED          3
   23 };
   24 
   25 #define RLN_NMBOX       0x7c                    /* Same as max msg seq number */
   26 
   27 /* Soft state */
   28 struct rln_softc {
   29         struct          device sc_dev;
   30         void            *sc_ih;                 /* Interrupt handler */
   31         struct          arpcom sc_arpcom;       /* Ethernet common part */
   32         bus_space_tag_t sc_iot;                 /* Bus cookie */
   33         bus_space_handle_t sc_ioh;              /* Bus i/o handle */
   34         struct timeout  sc_timeout;
   35 
   36         u_int8_t        sc_width;               /* Bus transfer width */
   37         u_int8_t        sc_irq;                 /* IRQ for card */
   38 
   39         u_int16_t       sc_cardtype;            /* Set from config flags */
   40 #define RLN_CTYPE_OEM           0x01
   41 #define RLN_CTYPE_UISA          0x02
   42 #define RLN_CTYPE_ONE_PIECE     0x04
   43 
   44         u_int8_t        sc_intsel;              /* Copy of INTSEL */
   45         u_int8_t        sc_status;              /* Copy of STATUS */
   46         u_int8_t        sc_control;             /* Copy of CONTROL */
   47 #ifdef RLNDEBUG_REG
   48         u_int16_t       dbg_oreg[8];            /* Last reg value written */
   49 #endif
   50 
   51         u_int8_t        sc_pktseq;              /* Card message seq no */
   52         u_int8_t        sc_txseq;               /* Tx packet seq no */
   53 
   54         u_int16_t       sc_state;               /* Soft state. */
   55 #define RLN_STATE_SYNC          0x0001  /* Card is synchronised */
   56 #define RLN_STATE_NEEDINIT      0x0002  /* Card needs reset+init */
   57 #define RLN_STATE_PROMISC       0x0004  /* Receive all packets */
   58 
   59         struct          rln_mbox sc_mbox[0x80]; /* Per-message mailboxes */
   60         struct          rln_param sc_param;     /* User controlled parameters */
   61 };
   62 
   63 #define rln_need_reset(sc) \
   64         (sc)->sc_state |= RLN_STATE_NEEDINIT
   65 
   66 /* Structure used to hold partial read state for rln_rx_pdata() */
   67 struct rln_pdata {
   68         u_int8_t p_data;                /* extra data read but not consumed */
   69         int      p_nremain;             /* size of unconsumed data */
   70 };
   71 #define RLN_PDATA_INIT {0,0}
   72 
   73 /* Structure used to hold partial transmit state for rln_msg_tx_*() */
   74 struct rln_msg_tx_state {
   75         int      ien;                   /* saved interrupt state */
   76         u_int8_t w;                     /* saved wakup state */
   77         struct rln_pdata pd;            /* saved partial write state */
   78 };
   79 
   80 struct rln_mm_cmd;                      /* fwd decl */
   81 
   82 #define RLN_WAKEUP_SET          0xff
   83 #define RLN_WAKEUP_NOCHANGE     (0x80|0x10)
   84 
   85 void            rlnconfig(struct rln_softc *);
   86 int             rlnintr(void *);
   87 void            rlninit(struct rln_softc *);
   88 void            rlnstop(struct rln_softc *);
   89 void            rlnread(struct rln_softc *, struct rln_mm_cmd *, int);
   90 int             rln_enable(struct rln_softc *, int);
   91 int             rln_reset(struct rln_softc *);
   92 u_int8_t        rln_wakeup(struct rln_softc *, u_int8_t);
   93 int             rln_rx_request(struct rln_softc *, int);
   94 int             rln_rx_data(struct rln_softc *, void *, int);
   95 void            rln_rx_pdata(struct rln_softc *, void *, int,
   96                         struct rln_pdata *);
   97 void            rln_rx_end(struct rln_softc *);
   98 void            rln_clear_nak(struct rln_softc *);
   99 u_int8_t        rln_newseq(struct rln_softc *);
  100 
  101 void            rln_msg_tx_data(struct rln_softc *, void *, u_int16_t,
  102                         struct rln_msg_tx_state *);
  103 int             rln_msg_tx_start(struct rln_softc *, void *, int,
  104                         struct rln_msg_tx_state *);
  105 int             rln_msg_tx_end(struct rln_softc *, 
  106                         struct rln_msg_tx_state *);
  107 int             rln_msg_txrx(struct rln_softc *, void *, int, 
  108                         void *, int);
  109 
  110 int             rln_mbox_create(struct rln_softc *, u_int8_t, void *,
  111                         size_t);
  112 int             rln_mbox_wait(struct rln_softc *, u_int8_t, int);
  113 int             rln_mbox_lock(struct rln_softc *, u_int8_t, void **,
  114                         size_t*);
  115 void            rln_mbox_unlock(struct rln_softc *, u_int8_t, size_t);
  116 
  117 /* debug all card operations */
  118 #ifdef RLNDEBUG
  119 #define dprintf(fmt, args...) printf(fmt , ## args)
  120         /* log(LOG_DEBUG, fmt , ## args) */
  121 #define dprinthex(buf, len)     do {                            \
  122         unsigned char *_b = (unsigned char *)(buf);             \
  123         int _i, _l=(len);                                       \
  124         printf("{");                                            \
  125         for(_i = 0; _i < _l; _i++) {                            \
  126                 printf("%02x", _b[_i]);                         \
  127                 if (_i % 4 == 3 && _i != _l - 1)                \
  128                         printf(",");                            \
  129         }                                                       \
  130         printf("}");                                            \
  131 } while (0)
  132 #else
  133 #define dprintf(fmt, args...) /* nothing */
  134 #define dprinthex(buf, len)     /* nothing */
  135 #endif
  136 
  137 /* debug messages to/from card. prints 4-octet groups separated by commas */
  138 #define RLNDUMP
  139 #define RLNDUMPHEX(buf, buflen) do {                            \
  140         int _i;                                                 \
  141         for (_i = 0; _i < (buflen); _i++) {                     \
  142                 printf("%02x", ((unsigned char *)(buf))[_i]);   \
  143                 if (_i != (buflen) - 1 && _i % 4 == 3)          \
  144                         printf(",");                            \
  145         }                                                       \
  146 } while (0)

/* [<][>][^][v][top][bottom][index][help] */