[BACK]Return to if_san_common.h CVS log [TXT][DIR] Up to [local] / sys / dev / pci

Annotation of sys/dev/pci/if_san_common.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: if_san_common.h,v 1.8 2005/11/08 20:23:42 canacar Exp $       */
        !             2:
        !             3: /*-
        !             4:  * Copyright (c) 2001-2004 Sangoma Technologies (SAN)
        !             5:  * All rights reserved.  www.sangoma.com
        !             6:  *
        !             7:  * This code is written by Alex Feldman <al.feldman@sangoma.com> for SAN.
        !             8:  *
        !             9:  * Redistribution and use in source and binary forms, with or without
        !            10:  * modification, are permitted provided that the following conditions
        !            11:  * are met:
        !            12:  * 1. Redistributions of source code must retain the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer.
        !            14:  * 2. Redistributions in binary form must reproduce the above
        !            15:  *    copyright notice, this list of conditions and the following disclaimer
        !            16:  *    in the documentation and/or other materials provided with the
        !            17:  *    distribution.
        !            18:  * 3. Neither the name of Sangoma Technologies nor the names of its
        !            19:  *    contributors may be used to endorse or promote products derived
        !            20:  *    from this software without specific prior written permission.
        !            21:  *
        !            22:  * THIS SOFTWARE IS PROVIDED BY SANGOMA TECHNOLOGIES AND CONTRIBUTORS
        !            23:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            24:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            25:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            26:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            27:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            28:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            29:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            30:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            31:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
        !            32:  * THE POSSIBILITY OF SUCH DAMAGE.
        !            33:  */
        !            34:
        !            35: #ifndef        __IF_SAN_COMMON_H
        !            36: #define        __IF_SAN_COMMON_H
        !            37:
        !            38: # include <dev/pci/if_san_te1.h>
        !            39: # include <dev/pci/if_sandrv.h>
        !            40:
        !            41: #define ADDR_MASK(x,y) (((caddr_t)(x) - (caddr_t)0) & (y))
        !            42:
        !            43: #define WANPIPE_LITE_VERSION   "1.1.1"
        !            44: #define WAN_OPENBSD_PLATFORM   0x06
        !            45: #define WAN_PLATFORM_ID        WAN_OPENBSD_PLATFORM
        !            46: #define        WANPIPE_MAGIC   0x414C4453L     /* signature: 'SDLA' reversed */
        !            47:
        !            48: #define        ROUTER_NAME     "wanrouter"     /* in case we ever change it */
        !            49: #define        ROUTER_IOCTL    'W'             /* for IOCTL calls */
        !            50:
        !            51: #define WANROUTER_MAJOR_VER    2
        !            52: #define WANROUTER_MINOR_VER    1
        !            53:
        !            54: /* IOCTL codes for /proc/router/<device> entries (up to 255) */
        !            55: #define WANPIPE_DUMP   _IOW(ROUTER_IOCTL, 16, wan_conf_t)
        !            56: #define WANPIPE_EXEC   _IOWR(ROUTER_IOCTL, 17, wan_conf_t)
        !            57:
        !            58: /* get monitor statistics */
        !            59: #define SIOC_WANPIPE_PIPEMON   _IOWR('i', 150, struct ifreq)
        !            60:
        !            61: /* set generic device */
        !            62: #define SIOC_WANPIPE_DEVICE    _IOWR('i', 151, struct ifreq)
        !            63:
        !            64: /* get hwprobe string */
        !            65: #define SIOC_WANPIPE_HWPROBE   _IOWR('i', 152, struct ifreq)
        !            66:
        !            67: /* get memdump string (GENERIC) */
        !            68: #define SIOC_WANPIPE_DUMP      _IOWR('i', 153, struct ifreq)
        !            69:
        !            70:
        !            71: /* clocking options */
        !            72: #define        WAN_EXTERNAL    0
        !            73: #define        WAN_INTERNAL    1
        !            74:
        !            75: /* intercace options */
        !            76: #define        WAN_RS232       0
        !            77: #define        WAN_V35 1
        !            78:
        !            79: #define WAN_UDP_FAILED_CMD     0xCF
        !            80: #define WAN_UDP_INVALID_CMD    0xCE
        !            81: #define WAN_UDP_TIMEOUT_CMD    0xAA
        !            82: #define WAN_UDP_INVALID_NET_CMD     0xCD
        !            83:
        !            84: #define        WAN_NO  0
        !            85: #define        WAN_YES 1
        !            86:
        !            87: /* UDP Packet Management */
        !            88: #define UDP_PKT_FRM_STACK      0x00
        !            89: #define UDP_PKT_FRM_NETWORK    0x01
        !            90:
        !            91: #define        WANCONFIG_FR    102     /* frame relay link */
        !            92: #define        WANCONFIG_PPP   103     /* synchronous PPP link */
        !            93: #define WANCONFIG_CHDLC        104     /* Cisco HDLC Link */
        !            94: #define WANCONFIG_AFT    117   /* AFT Hardware Support */
        !            95: /****** Data Types **********************************************************/
        !            96:
        !            97:
        !            98: /* Front-End status */
        !            99: enum fe_status {
        !           100:        FE_UNITIALIZED = 0x00,
        !           101:        FE_DISCONNECTED,
        !           102:        FE_CONNECTED
        !           103: };
        !           104:
        !           105: /* 'state' defines */
        !           106: enum wan_states
        !           107: {
        !           108:        WAN_UNCONFIGURED,       /* link/channel is not configured */
        !           109:        WAN_DISCONNECTED,       /* link/channel is disconnected */
        !           110:        WAN_CONNECTING,         /* connection is in progress */
        !           111:        WAN_CONNECTED,          /* link/channel is operational */
        !           112:        WAN_LIMIT,              /* for verification only */
        !           113:        WAN_DUALPORT,           /* for Dual Port cards */
        !           114:        WAN_DISCONNECTING,
        !           115:        WAN_FT1_READY           /* FT1 Configurator Ready */
        !           116: };
        !           117:
        !           118: /* 'modem_status' masks */
        !           119: #define        WAN_MODEM_CTS   0x0001  /* CTS line active */
        !           120: #define        WAN_MODEM_DCD   0x0002  /* DCD line active */
        !           121: #define        WAN_MODEM_DTR   0x0010  /* DTR line active */
        !           122: #define        WAN_MODEM_RTS   0x0020  /* RTS line active */
        !           123:
        !           124: typedef struct wan_conf {
        !           125:        char    devname[IFNAMSIZ+1];
        !           126:        void*   arg;
        !           127: } wan_conf_t;
        !           128:
        !           129:
        !           130: /* IOCTL numbers (up to 16) */
        !           131:
        !           132: #define TRACE_ALL                       0x00
        !           133: #define TRACE_PROT                     0x01
        !           134: #define TRACE_DATA                     0x02
        !           135:
        !           136: /* values for request/reply byte */
        !           137: #define UDPMGMT_REQUEST        0x01
        !           138: #define UDPMGMT_REPLY  0x02
        !           139: #define UDP_OFFSET     12
        !           140:
        !           141: #define MAX_FT1_RETRY  100
        !           142:
        !           143: /* General Critical Flags */
        !           144: enum {
        !           145:        SEND_CRIT,
        !           146:        PERI_CRIT,
        !           147:        RX_CRIT,
        !           148:        PRIV_CRIT
        !           149: };
        !           150:
        !           151: /*
        !           152:  * Data structures for IOCTL calls.
        !           153:  */
        !           154:
        !           155: typedef struct sdla_dump {     /* WANPIPE_DUMP */
        !           156:        unsigned long   magic;  /* for verification */
        !           157:        unsigned long   offset; /* absolute adapter memory address */
        !           158:        unsigned long   length; /* block length */
        !           159:        void*           ptr;    /* -> buffer */
        !           160: } sdla_dump_t;
        !           161:
        !           162: typedef struct sdla_exec {     /* WANPIPE_EXEC */
        !           163:        unsigned long   magic;  /* for verification */
        !           164:        void*           cmd;    /* -> command structure */
        !           165:        void*           data;   /* -> data buffer */
        !           166: } sdla_exec_t;
        !           167:
        !           168: #define TRC_INCOMING_FRM       0x00
        !           169: #define TRC_OUTGOING_FRM       0x01
        !           170: typedef struct {
        !           171:        unsigned char   status;
        !           172:        unsigned char   data_avail;
        !           173:        unsigned short  real_length;
        !           174:        unsigned short  time_stamp;
        !           175:        unsigned long   sec;
        !           176:        unsigned long   usec;
        !           177:        unsigned char   data[0];
        !           178: } wan_trace_pkt_t;
        !           179:
        !           180: typedef struct wan_trace {
        !           181:        unsigned long   tracing_enabled;
        !           182:        struct ifqueue  ifq;
        !           183:        unsigned int    trace_timeout;
        !           184:        unsigned int    max_trace_queue;
        !           185: } wan_trace_t;
        !           186:
        !           187:
        !           188: /********************************************************
        !           189:  *     GLOBAL DEFINITION FOR SANGOMA UDP STRUCTURE     *
        !           190:  *******************************************************/
        !           191: #define GLOBAL_UDP_SIGNATURE           "WANPIPE"
        !           192: #define GLOBAL_UDP_SIGNATURE_LEN       7
        !           193: #define UDPMGMT_UDP_PROTOCOL           0x11
        !           194: #define WAN_UDP_CMD_START      0x60
        !           195: #define WAN_GET_PROTOCOL       (WAN_UDP_CMD_START+0)
        !           196: #define WAN_GET_PLATFORM       (WAN_UDP_CMD_START+1)
        !           197: #define WAN_GET_MEDIA_TYPE     (WAN_UDP_CMD_START+2)
        !           198: #define WAN_UDP_CMD_END                0x6F
        !           199:
        !           200: #define WAN_FE_CMD_START       0x90
        !           201: #define WAN_FE_CMD_END         0x9F
        !           202:
        !           203: #define WAN_INTERFACE_CMD_START        0xA0
        !           204: #define WAN_INTERFACE_CMD_END  0xAF
        !           205:
        !           206: #define WAN_FE_UDP_CMD_START   0xB0
        !           207: #define WAN_FE_UDP_CMD_END     0xBF
        !           208:
        !           209: typedef struct {
        !           210:        unsigned char   signature[8];
        !           211:        unsigned char   request_reply;
        !           212:        unsigned char   id;
        !           213:        unsigned char   reserved[6];
        !           214: } wan_mgmt_t;
        !           215:
        !           216:
        !           217: /****** DEFINITION OF UDP HEADER AND STRUCTURE PER PROTOCOL ******/
        !           218: typedef struct {
        !           219:        unsigned char   num_frames;
        !           220:        unsigned char   ismoredata;
        !           221: } wan_trace_info_t;
        !           222:
        !           223: typedef struct wan_udp_hdr{
        !           224:        wan_mgmt_t      wan_mgmt;
        !           225:        wan_cmd_t       wan_cmd;
        !           226:        union {
        !           227:                struct {
        !           228:                        wan_trace_info_t        trace_info;
        !           229:                        unsigned char           data[WAN_MAX_DATA_SIZE];
        !           230:                } chdlc, aft;
        !           231:                unsigned char data[WAN_MAX_DATA_SIZE];
        !           232:        } wan_udphdr_u;
        !           233: #define wan_udphdr_signature           wan_mgmt.signature
        !           234: #define wan_udphdr_request_reply       wan_mgmt.request_reply
        !           235: #define wan_udphdr_id                  wan_mgmt.id
        !           236: #define wan_udphdr_opp_flag            wan_cmd.wan_cmd_opp_flag
        !           237: #define wan_udphdr_command             wan_cmd.wan_cmd_command
        !           238: #define wan_udphdr_data_len            wan_cmd.wan_cmd_data_len
        !           239: #define wan_udphdr_return_code         wan_cmd.wan_cmd_return_code
        !           240: #define wan_udphdr_chdlc_num_frames    wan_udphdr_u.chdlc.trace_info.num_frames
        !           241: #define wan_udphdr_chdlc_ismoredata    wan_udphdr_u.chdlc.trace_info.ismoredata
        !           242: #define wan_udphdr_chdlc_data          wan_udphdr_u.chdlc.data
        !           243:
        !           244: #define wan_udphdr_aft_num_frames      wan_udphdr_u.aft.trace_info.num_frames
        !           245: #define wan_udphdr_aft_ismoredata      wan_udphdr_u.aft.trace_info.ismoredata
        !           246: #define wan_udphdr_aft_data            wan_udphdr_u.aft.data
        !           247: #define wan_udphdr_data                        wan_udphdr_u.data
        !           248: } wan_udp_hdr_t;
        !           249:
        !           250: #define MAX_LGTH_UDP_MGNT_PKT 2000
        !           251:
        !           252: /* This is used for interrupt testing */
        !           253: #define INTR_TEST_MODE 0x02
        !           254:
        !           255: #define        WUM_SIGNATURE_L 0x50495046
        !           256: #define        WUM_SIGNATURE_H 0x444E3845
        !           257:
        !           258: #define        WUM_KILL        0x50
        !           259: #define        WUM_EXEC        0x51
        !           260:
        !           261:
        !           262: #if defined(_KERNEL)
        !           263: /****** Kernel Interface ****************************************************/
        !           264:
        !           265:
        !           266: #define MAX_E1_CHANNELS 32
        !           267: #define MAX_FR_CHANNELS (991+1)
        !           268:
        !           269: #ifndef        min
        !           270: #define min(a,b) (((a)<(b))?(a):(b))
        !           271: #endif
        !           272: #ifndef        max
        !           273: #define max(a,b) (((a)>(b))?(a):(b))
        !           274: #endif
        !           275:
        !           276: #define        is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
        !           277:
        !           278: #define        is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||     \
        !           279:                ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
        !           280:
        !           281: #define        is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')|| \
        !           282:                ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
        !           283:                ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
        !           284: #if !defined(offsetof)
        !           285: # define offsetof(type, member)        ((size_t)(&((type*)0)->member))
        !           286: #endif
        !           287:
        !           288: # define irqreturn_t   void
        !           289: /* Unsafe sprintf and vsprintf function removed from the kernel */
        !           290: # define WAN_IRQ_RETVAL(a)             return;
        !           291:
        !           292: #define        _bit_byte(bit) ((bit) >> 3)
        !           293: #define        _bit_mask(bit) (1 << ((bit)&0x7))
        !           294:
        !           295: /* is bit N of bitstring name set? */
        !           296: #define        bit_test(name, bit) ((name)[_bit_byte(bit)] & _bit_mask(bit))
        !           297:
        !           298: /* set bit N of bitstring name */
        !           299: #define        bit_set(name, bit) ((name)[_bit_byte(bit)] |= _bit_mask(bit))
        !           300:
        !           301: /* clear bit N of bitstring name */
        !           302: #define        bit_clear(name, bit) ((name)[_bit_byte(bit)] &= ~_bit_mask(bit))
        !           303:
        !           304: /* Sangoma assert macro */
        !           305: #define SAN_ASSERT(a)                                          \
        !           306:        if (a){                                                 \
        !           307:                log(LOG_INFO, "%s:%d: Critical Error!\n",       \
        !           308:                                __FUNCTION__,__LINE__);         \
        !           309:                return (EINVAL);                                \
        !           310:        }
        !           311:
        !           312: /****** Data Structures *****************************************************/
        !           313:
        !           314: typedef struct wan_udp_pkt {
        !           315:        struct ip       ip_hdr;
        !           316:        struct udphdr   udp_hdr;
        !           317:        wan_udp_hdr_t   wan_udp_hdr;
        !           318: #define wan_udp_cmd                    wan_udp_hdr.wan_cmd
        !           319: #define wan_udp_signature              wan_udp_hdr.wan_udphdr_signature
        !           320: #define wan_udp_request_reply          wan_udp_hdr.wan_udphdr_request_reply
        !           321: #define wan_udp_id                     wan_udp_hdr.wan_udphdr_id
        !           322: #define wan_udp_opp_flag               wan_udp_hdr.wan_udphdr_opp_flag
        !           323: #define wan_udp_command                        wan_udp_hdr.wan_udphdr_command
        !           324: #define wan_udp_data_len               wan_udp_hdr.wan_udphdr_data_len
        !           325: #define wan_udp_return_code            wan_udp_hdr.wan_udphdr_return_code
        !           326: #define wan_udp_hdlc_PF_bit            wan_udp_hdr.wan_udphdr_hdlc_PF_bit
        !           327: #define wan_udp_fr_dlci                        wan_udp_hdr.wan_udphdr_fr_dlci
        !           328: #define wan_udp_fr_attr                        wan_udp_hdr.wan_udphdr_fr_attr
        !           329: #define wan_udp_fr_rxlost1             wan_udp_hdr.wan_udphdr_fr_rxlost1
        !           330: #define wan_udp_fr_rxlost2             wan_udp_hdr.wan_udphdr_fr_rxlost2
        !           331: #define wan_udp_chdlc_num_frames       wan_udp_hdr.wan_udphdr_chdlc_num_frames
        !           332: #define wan_udp_chdlc_ismoredata       wan_udp_hdr.wan_udphdr_chdlc_ismoredata
        !           333: #define wan_udp_chdlc_data             wan_udp_hdr.wan_udphdr_chdlc_data
        !           334:
        !           335: #define wan_udp_aft_num_frames         wan_udp_hdr.wan_udphdr_aft_num_frames
        !           336: #define wan_udp_aft_ismoredata         wan_udp_hdr.wan_udphdr_aft_ismoredata
        !           337: #define wan_udp_data                   wan_udp_hdr.wan_udphdr_data
        !           338: } wan_udp_pkt_t;
        !           339:
        !           340: #define WAN_IFP_TO_COMMON(ifp) (wanpipe_common_t*)((ifp)->if_softc)
        !           341: typedef struct wanpipe_common {
        !           342:        struct sppp     ifp;
        !           343:        void            *card;
        !           344:        struct timeout  dev_timer;
        !           345:        unsigned int    protocol;
        !           346:        struct ifmedia  ifm;
        !           347:
        !           348:        LIST_ENTRY(wanpipe_common)      next;
        !           349: } wanpipe_common_t;
        !           350:
        !           351: typedef struct {
        !           352:        unsigned long   time_slot_map;
        !           353:        unsigned long   logic_ch_map;
        !           354:        unsigned char   num_of_time_slots;
        !           355:        unsigned char   top_logic_ch;
        !           356:        unsigned long   bar;
        !           357:        void            *trace_info;
        !           358:        void            *dev_to_ch_map[MAX_E1_CHANNELS];
        !           359:        void            *rx_dma_ptr;
        !           360:        void            *tx_dma_ptr;
        !           361:        unsigned short  num_of_ch;/* Number of logical channels */
        !           362:        unsigned short  dma_per_ch;/* DMA buffers per logic channel */
        !           363:        unsigned short  mru_trans;/* MRU of transparent channels */
        !           364:        unsigned long   dma_mtu_off;
        !           365:        unsigned short  dma_mtu;
        !           366:        unsigned char   state_change_exit_isr;
        !           367:        unsigned long   active_ch_map;
        !           368:        unsigned long   fifo_addr_map;
        !           369:        struct timeout  led_timer;
        !           370: } sdla_xilinx_t;
        !           371:
        !           372: /* Adapter Data Space.
        !           373:  * This structure is needed because we handle multiple cards, otherwise
        !           374:  * static data would do it.
        !           375:  */
        !           376: typedef struct sdla {
        !           377:        unsigned        magic;
        !           378:        char            devname[IFNAMSIZ+1];    /* card name */
        !           379:        void            *hw;                    /* hw configuration */
        !           380:        unsigned int    type;                   /* adapter type */
        !           381:        unsigned char   line_idle;
        !           382:
        !           383:        char            state;          /* device state */
        !           384:        unsigned long   critical;       /* critical section flag */
        !           385:
        !           386:        int(*iface_up) (struct ifnet*);
        !           387:        int(*iface_down) (struct ifnet*);
        !           388:        int(*iface_send) (struct mbuf* skb, struct ifnet*);
        !           389:        int(*iface_ioctl) (struct ifnet*, int, struct ifreq*);
        !           390:
        !           391:        unsigned long   state_tick;     /* link state timestamp */
        !           392:        unsigned long   in_isr;         /* interrupt-in-service flag */
        !           393:        unsigned long   configured;     /* configurations status */
        !           394:        int(*del_if) (struct sdla*, struct ifnet*);
        !           395:        void(*isr)(struct sdla*);       /* interrupt service routine */
        !           396:        void(*poll)(struct sdla*);      /* polling routine */
        !           397:        int(*exec)(struct sdla*, void*, void*);
        !           398:        int(*ioctl) (struct ifnet*, int, struct ifreq*);
        !           399:
        !           400:        union {
        !           401:                sdla_xilinx_t   xilinx;
        !           402:        } u;
        !           403:
        !           404:        sdla_fe_iface_t fe_iface;
        !           405:        union {
        !           406: #define fe_te  u_fe.te_sc
        !           407:                sdla_te_softc_t te_sc;
        !           408:        } u_fe;
        !           409:
        !           410:        unsigned char           front_end_status;
        !           411:        WRITE_FRONT_END_REG_T*  write_front_end_reg;
        !           412:        READ_FRONT_END_REG_T*   read_front_end_reg;
        !           413:        void(*te_enable_timer) (void*);
        !           414:        void(*te_link_state)  (void*);
        !           415:
        !           416:        LIST_HEAD(,wanpipe_common)      dev_head;
        !           417:        LIST_ENTRY(sdla)                next;   /* -> next device */
        !           418: } sdla_t;
        !           419:
        !           420: /****** Public Functions ****************************************************/
        !           421:
        !           422: void*          wan_xilinx_init(sdla_t*);       /* Xilinx Hardware Support */
        !           423: struct mbuf*   wan_mbuf_alloc(int);
        !           424: int            wan_mbuf_to_buffer(struct mbuf**);
        !           425:
        !           426: #endif /* __KERNEL__ */
        !           427: #endif /* __IF_SAN_COMMON_H */

CVSweb