Annotation of XNU/iokit/Drivers/network/drvIntel82557/i82557.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * Copyright (c) 1996 NeXT Software, Inc.
        !            24:  *
        !            25:  * i82557.h
        !            26:  *
        !            27:  * HISTORY
        !            28:  *
        !            29:  * 4-Mar-96    Dieter Siegmund (dieter) at NeXT
        !            30:  *             Created.
        !            31:  */
        !            32: 
        !            33: #ifndef _I82557_H
        !            34: #define _I82557_H
        !            35: 
        !            36: #include <IOKit/pci/IOPCIDevice.h>
        !            37: #include <IOKit/network/IOEthernetController.h>
        !            38: #include <IOKit/network/IOEthernetInterface.h>
        !            39: #include <IOKit/network/IOOQGateFIFOQueue.h>
        !            40: #include <IOKit/network/IOMBufMemoryCursor.h>
        !            41: #include <IOKit/network/IOPacketQueue.h>
        !            42: #include <IOKit/IOTimerEventSource.h>
        !            43: #include <IOKit/IODeviceMemory.h>
        !            44: #include <IOKit/IOInterruptEventSource.h>
        !            45: #include <IOKit/IOFilterInterruptEventSource.h>
        !            46: 
        !            47: #include "i82557Inline.h"
        !            48: #include "i82557eeprom.h"
        !            49: #include "i82557PHY.h"
        !            50: #include <IOKit/assert.h>
        !            51: 
        !            52: #ifndef __ppc__
        !            53: //
        !            54: // Intel interrupt hack. This prevents a hang when the driver
        !            55: // services the interrupt.
        !            56: //
        !            57: #define USE_FILTER_INTERRUPT_EVENT_SRC 1
        !            58: #endif
        !            59: 
        !            60: /*
        !            61:  * Macro: VPRINT
        !            62:  *
        !            63:  * Purpose:
        !            64:  *   Dump stuff to console log if the "Verbose" key is present in
        !            65:  *   the device description.
        !            66:  */
        !            67: #define VPRINT(fmt, args...) \
        !            68:        if (verbose) \
        !            69:                IOLog(fmt, ## args);
        !            70: 
        !            71: #define NUM_RECEIVE_FRAMES             32
        !            72: #define NUM_TRANSMIT_FRAMES            32
        !            73: 
        !            74: #define TRANSMIT_INT_DELAY             8
        !            75: #define TRANSMIT_QUEUE_SIZE            256
        !            76: 
        !            77: #define MAX_BUF_SIZE                   (ETHERMAXPACKET + ETHERCRC)
        !            78: 
        !            79: #define SPIN_TIMEOUT                   50000
        !            80: #define SPIN_COUNT                             1
        !            81: 
        !            82: /*
        !            83:  * Type: tcbQ_t
        !            84:  *
        !            85:  * Purpose:
        !            86:  *   Hold transmit hardware queue variables.
        !            87:  */
        !            88: typedef struct {
        !            89:     int                        numTcbs;
        !            90:        tcb_t *         activeHead_p;
        !            91:        tcb_t *         activeTail_p;
        !            92:        tcb_t *         freeHead_p;
        !            93:     int                        numFree;
        !            94: } tcbQ_t;
        !            95: 
        !            96: /*
        !            97:  * Type: overlay_t
        !            98:  *
        !            99:  * Purpose:
        !           100:  *   Overlayable memory used during start-up.
        !           101:  */
        !           102: typedef union {
        !           103:     cbHeader_t                 nop;
        !           104:     cb_configure_t             configure;
        !           105:     cb_iasetup_t               iasetup;
        !           106:     port_selftest_t    selftest;
        !           107: } overlay_t;
        !           108: 
        !           109: /*
        !           110:  * Type: pageBlock_t
        !           111:  *
        !           112:  * Purpose:
        !           113:  *   Track a page sized memory block.
        !           114:  */
        !           115: typedef struct {
        !           116:     void *     memPtr;
        !           117:     UInt       memSize;
        !           118:     void *     memAllocPtr;
        !           119:     UInt       memAvail;
        !           120: } pageBlock_t;
        !           121: 
        !           122: /*
        !           123:  * Adapter activation levels.
        !           124:  */
        !           125: enum {
        !           126:        kAdapterLevel0 = 0,
        !           127:        kAdapterLevel1,
        !           128:        kAdapterLevel2
        !           129: };
        !           130: 
        !           131: class Intel82557 : public IOEthernetController
        !           132: {
        !           133:        OSDeclareDefaultStructors(Intel82557)
        !           134: 
        !           135: public:
        !           136:     IOPhysicalAddress              memBasePhysical;
        !           137:     int                            irq;
        !           138:     enet_addr_t                    myAddress;
        !           139:     IOEthernetInterface        *          netif;
        !           140:        IOKernelDebugger *             debugger;
        !           141: 
        !           142: #if USE_FILTER_INTERRUPT_EVENT_SRC
        !           143:        IOFilterInterruptEventSource * interruptSrc;
        !           144: #else
        !           145:        IOInterruptEventSource *       interruptSrc;
        !           146: #endif
        !           147: 
        !           148:        IOOQGateFIFOQueue *            transmitQueue;
        !           149:        IOTimerEventSource *           timerSrc;
        !           150:        IONetworkStats *               netStats;
        !           151:        IOEthernetStats *              etherStats;
        !           152:        IOMemoryMap *                  csrMap;
        !           153:        OSDictionary *                 mediumDict;
        !           154:        IONetworkMedium *              mediumTable[MEDIUM_TYPE_INVALID];
        !           155: 
        !           156:        IOMBufLittleMemoryCursor *     rxMbufCursor;
        !           157:        IOMBufLittleMemoryCursor *     txMbufCursor;
        !           158: 
        !           159:     int                            txCount;
        !           160:        UInt32                         currentLevel;
        !           161:        bool                           enabledForNetif;
        !           162:        bool                           enabledForDebugger;
        !           163:     bool                           promiscuousEnabled;
        !           164:     bool                           multicastEnabled;
        !           165:     bool                           allMulticastEnabled;
        !           166:        bool                           interruptEnabled;
        !           167:     bool                           packetsReceived;
        !           168:     bool                           packetsTransmitted;
        !           169:     bool                           verbose;
        !           170:        bool                                               flowControl;
        !           171:        mediumType_t                   currentMediumType;
        !           172:     UInt8                          phyAddr;
        !           173:        UInt32                         phyID;
        !           174: 
        !           175:     /* descriptor and control block data structures */
        !           176:        pageBlock_t                    shared;
        !           177:        pageBlock_t                    rxRing;
        !           178:        pageBlock_t                    txRing;
        !           179:        
        !           180:        CSR_t *                        CSR_p;
        !           181:     overlay_t *                    overlay_p;
        !           182:     IOPhysicalAddress              overlay_paddr;
        !           183:     errorCounters_t *              errorCounters_p;
        !           184:     IOPhysicalAddress              errorCounters_paddr;
        !           185:     i82557eeprom *                 eeprom;
        !           186: 
        !           187:     /* transmit-related */
        !           188:     tcbQ_t                         tcbQ;
        !           189:        tcb_t *                        tcbList_p;
        !           190:     int                            prevCUCommand;
        !           191: 
        !           192:     /* kernel debugger */
        !           193:        tcb_t *                        KDB_tcb_p;
        !           194:     void *                         KDB_buf_p;
        !           195:     IOPhysicalAddress              KDB_buf_paddr;
        !           196:     
        !           197:     /* receive-related */
        !           198:        rfd_t *                        rfdList_p;       
        !           199:        rfd_t *                        headRfd;
        !           200:        rfd_t *                        tailRfd;
        !           201: 
        !           202:        // --------------------------------------------------
        !           203:        // IOService (or its superclass) methods.
        !           204:        // --------------------------------------------------
        !           205: 
        !           206:        virtual bool init(OSDictionary * properties);
        !           207: 
        !           208:        virtual IOService * Intel82557::probe(IOService * provider,
        !           209:                                           SInt32 *    score);
        !           210: 
        !           211:        virtual bool start(IOService * provider);
        !           212:        virtual void stop(IOService * provider);
        !           213: 
        !           214:        virtual void free();
        !           215: 
        !           216:        // --------------------------------------------------
        !           217:        // IONetworkController methods.
        !           218:        // --------------------------------------------------
        !           219: 
        !           220:        virtual IOReturn enable(IONetworkInterface * netif);
        !           221:        virtual IOReturn disable(IONetworkInterface * netif);
        !           222: 
        !           223:        virtual IOReturn enable(IOKernelDebugger * debugger);
        !           224:        virtual IOReturn disable(IOKernelDebugger * debugger);
        !           225: 
        !           226:        virtual void sendPacket(void * pkt, UInt pkt_len);
        !           227:        virtual void receivePacket(void * pkt, UInt * pkt_len, UInt timeout);
        !           228: 
        !           229:        virtual UInt32 outputPacket(struct mbuf * m);
        !           230: 
        !           231:        virtual void getPacketBufferConstraints(
        !           232:                  IOPacketBufferConstraints * constraints) const;
        !           233: 
        !           234:        virtual IOOutputQueue * createOutputQueue();
        !           235: 
        !           236:        virtual const char * getVendorString() const;
        !           237:        virtual const char * getModelString() const;
        !           238:        virtual const char * getRevisionString() const;
        !           239: 
        !           240:        virtual IOReturn setMedium(const IONetworkMedium * medium);
        !           241: 
        !           242:        virtual bool configureInterface(IONetworkInterface * interface);
        !           243: 
        !           244:        // --------------------------------------------------
        !           245:        // IOEthernetController methods.
        !           246:        // --------------------------------------------------
        !           247: 
        !           248:        virtual IOReturn getHardwareAddress(enet_addr_t * addr);
        !           249:        virtual IOReturn setPromiscuousMode(IOEnetPromiscuousMode mode);
        !           250:        virtual IOReturn setMulticastMode(IOEnetMulticastMode mode);
        !           251:        virtual IOReturn setMulticastList(enet_addr_t *addrs, UInt count);
        !           252: 
        !           253:        // --------------------------------------------------
        !           254:        // Intel82557 driver specific methods.
        !           255:        // --------------------------------------------------
        !           256: 
        !           257:        bool pciConfigInit(IOPCIDevice * provider);
        !           258:        bool initDriver(IOService * provider);
        !           259:        bool coldInit();
        !           260:        bool enableAdapter(UInt32 level);
        !           261:        bool disableAdapter(UInt32 level);
        !           262:        bool setAdapterLevel(UInt32 newLevel);
        !           263:        bool config();
        !           264:        void disableAdapterInterrupts();
        !           265:        void enableAdapterInterrupts();
        !           266:        bool hwInit();
        !           267:        bool iaSetup();
        !           268:        bool mcSetup(enet_addr_t * addrs, UInt count, bool fromData = false);
        !           269:        bool nop();
        !           270:        void sendPortCommand(port_command_t command, UInt arg);
        !           271:        bool getDefaultSettings();
        !           272:        void issueReset();
        !           273:        void updateLinkStatus();
        !           274: 
        !           275:        bool _selfTest();
        !           276:        bool _allocateMemPage(pageBlock_t * p);
        !           277:        void _freeMemPage(pageBlock_t * p);
        !           278:        void _updateStatistics();
        !           279:        bool _dumpStatistics();
        !           280:        bool _mdiWritePHY(UInt8 phyAddress, UInt8 regAddress, UInt16 data);
        !           281:        bool _mdiReadPHY(UInt8 phyAddress, UInt8 regAddress, UInt16 * data_p);
        !           282:        void * _memAllocFrom(pageBlock_t * p, UInt allocSize, UInt align);
        !           283:        bool _polledCommand(cbHeader_t * hdr_p, IOPhysicalAddress paddr);
        !           284:        bool _abortReceive();
        !           285:        bool _startReceive();
        !           286:        void _resetChip();
        !           287: 
        !           288:        bool _initTcbQ(bool enable = false);
        !           289:        bool _initRfdList(bool enable = false);
        !           290:        bool _resetRfdList();
        !           291:        bool _initRingBuffers() {
        !           292:             return (_initTcbQ(true) && _initRfdList(true)); }  
        !           293:        bool _clearRingBuffers() {
        !           294:          return (_initTcbQ(false) && _initRfdList(false)); }
        !           295: 
        !           296:        bool _sendPacket(void * pkt, UInt len);
        !           297:        bool _receivePacket(void * pkt, UInt * len, UInt timeout);
        !           298: 
        !           299:        bool updateRFDFromMbuf(rfd_t * rfd_p, struct mbuf * m);
        !           300:        struct mbuf * updateTCBForMbuf(tcb_t * tcb_p, struct mbuf * m);
        !           301: 
        !           302: #ifdef USE_FILTER_INTERRUPT_EVENT_SRC
        !           303:        bool checkForInterrupt(IOFilterInterruptEventSource * src);
        !           304: #endif
        !           305:        void interruptOccurred(IOInterruptEventSource * src, int count);
        !           306:        bool receiveInterruptOccurred();
        !           307:        void transmitInterruptOccurred();
        !           308:        void timeoutOccurred(IOTimerEventSource * timer);
        !           309: 
        !           310:        // --------------------------------------------------
        !           311:        // PHY methods.
        !           312:        // --------------------------------------------------
        !           313: 
        !           314:        bool   _phyReset();
        !           315:        bool   _phyWaitAutoNegotiation();
        !           316:        UInt32 _phyGetID();
        !           317:        bool   _phySetMedium(mediumType_t medium);
        !           318:        bool   _phyProbe();
        !           319:        void   _phyPublishMedia();
        !           320:        bool   _phyAddMediumType(UInt32 type, UInt32 speed, UInt32 code);
        !           321: 
        !           322:        mediumType_t _phyGetMediumTypeFromBits(bool rate100,
        !           323:                                            bool fullDuplex,
        !           324:                                            bool t4);
        !           325: 
        !           326:        bool _phyGetLinkStatus(bool *         linkActive,
        !           327:                            mediumType_t * activeMedium,
        !           328:                            mediumType_t   selectedMedium);
        !           329: 
        !           330:        IONetworkMedium * _phyGetMediumWithCode(UInt32 code);
        !           331: };
        !           332: 
        !           333: #endif /* !_I82557_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.