background image

8

Sets the

if_version

member of the

ifnet

data structure for this

device to the string

3Com EtherLink III

.

6.7 Setting the Baud Rate

The following code shows how the

el_attach( )

routine sets the baud rate:

ifp->if_baudrate = ETHER_BANDWIDTH_10MB;

1

1

Sets the

if_baudrate

member of the

ifnet

data structure for this

device to the constant

ETHER_BANDWIDTH_10MB

. The

if_baudrate

member specifies the line speed.

You can use the following media-specific constants:

ETHER_BANDWIDTH_10MB

Ethernet line speed is 10 megabits per second.
The

if_ether.h

file defines the

ETHER_BAND-

WIDTH_10MB

constant.

ETHER_BANDWIDTH_100MB

Fast Ethernet line speed is 100 megabits per second.
The

if_ether.h

file defines the

ETHER_BAND-

WIDTH_100MB

constant.

FDDI_BANDWIDTH_100MB

FDDI line speed is 100 megabits per second. The

if_fddi.h

file defines the

FDDI_BANDWIDTH_100MB

constant.

TRN_BANDWIDTH_4MB

Token Ring line speed is 4 megabits per second. The

if_trn.h

file defines the

TRN_BANDWIDTH_4MB

constant.

TRN_BANDWIDTH_16MB

Token Ring line speed is 16 megabits per second. The

if_trn.h

file defines the

TRN_BANDWIDTH_16MB

constant.

6.8 Attaching to the Packet Filter and the Network Layer

The following code shows how the

el_attach( )

routine attaches to the

packet filter and the network layer:

attachpfilter(&(sc->is_ed));

1

if_attach(ifp);

2

el_conf+;

3

1

Calls the

attachpfilter( )

routine to inform the packet filter driver

about this network driver. The

attachpfilter( )

routine is passed

a pointer to the

ether_driver

data structure for this network device

driver.

6–8 Implementing the Autoconfiguration Support Section (attach)

Summary of Contents for Tru64 UNIX

Page 1: ...2000 Product Version Device Driver Kit Version 2 0 Operating System and Version Tru64 UNIX Version 5 0A or higher This manual contains information that systems engineers need to write network device...

Page 2: ...red for possession use or copying Consistent with FAR 12 211 and 12 212 Commercial Computer Software Computer Software Documentation and Technical Data for Commercial Items are licensed to the U S Gov...

Page 3: ...on for a Network Driver 1 11 1 9 ioctl Section for a Network Driver 1 11 1 10 Interrupt Section for a Network Driver 1 11 1 11 Output Section for a Network Driver 1 11 2 Defining Device Register Offse...

Page 4: ...be Routine 5 2 5 1 2 Checking the Maximum Number of Devices That the Driver Supports 5 4 5 1 3 Performing Bus Specific Tasks 5 4 5 1 4 Allocating Memory for the softc Data Structure 5 6 5 1 5 Allocati...

Page 5: ...and Media Header Lengths 6 2 6 3 Setting Up the Media 6 3 6 4 Initializing Simple Lock Information 6 5 6 5 Printing a Success Message 6 6 6 6 Specifying the Network Driver Interfaces 6 6 6 7 Setting...

Page 6: ...ia 8 6 8 2 6 Setting a LAN Attribute 8 7 8 2 7 Selecting Memory Mapping 8 7 8 2 8 Resetting the Transmitter and Receiver Again 8 7 8 2 9 Setting the LAN Address 8 8 8 2 10 Processing Special Flags 8 8...

Page 7: ...r the User Has Removed the PCMCIA Card from the Slot 12 3 12 3 Setting the IPL and Obtaining the Simple Lock 12 3 12 4 Enabling Loopback Mode SIOCENABLBACK ioctl Command 12 4 12 5 Disabling Loopback M...

Page 8: ...the el_rint Routine 13 5 13 2 1 Counting the Receive Interrupt and Reading the Receive Status 13 5 13 2 2 Pulling the Packets from the FIFO Buffer 13 6 13 2 3 Examining the First Part of the Packet 13...

Page 9: ...gnostic Registers 2 11 3 1 Typical softc Data Structure 3 2 3 2 Mapping Alternate Names 3 4 Tables 1 1 Driver Specific Macros 1 9 12 1 Network ioctl Commands 12 1 12 2 Network Interface Counter Types...

Page 10: ......

Page 11: ...on linked list data structures and multitasking Understand the hardware device for which the driver is being written Understand the basics of the CPU hardware architecture including interrupts direct...

Page 12: ...on is published by 3Com Corporation and the manual part number is 09 0398 002B You can access the if_el source code in the device driver examples directory if you have installed it on your system Ethe...

Page 13: ...the sections that make up a network driver and compares them to the sections that are associated with block and character drivers Chapter 2 Describes the device register offset definitions for the if...

Page 14: ...plement an interrupt handler using the if_el device driver s el_intr interrupt handler as an example Chapter 14 Describes the sysconfigtab option entries necessary for configuring network device drive...

Page 15: ...e and analyze a crash dump file Programming Support Tools describes several commands and utilities in the Tru64 UNIX system including facilities for text manipulation macro and program generation and...

Page 16: ...to the appropriate Compaq technical support office Information provided with the software media explains how to send problem reports to Compaq Conventions This manual uses the following conventions A...

Page 17: ...ation these brackets indicate items that are optional Vertical bars separating items that appear in the syntax definitions used in driver configuration indicate that you choose one item from among tho...

Page 18: ......

Page 19: ...A configure section Section 1 3 An autoconfiguration support section Section 1 4 An ioctl section Section 1 9 An interrupt section Section 1 10 Similar to a character device driver a network device d...

Page 20: ...on Reset Section Watchdog Section ZK 0818U AI Unlike for block and character drivers you do not specify network driver entry points in the dsent data structure This means that a network driver has no...

Page 21: ...network In the case of the Ethernet network interface the upper level code never hands off to the driver a single packet that exceeds 1514 bytes 1 1 Include Files Section for a Network Driver A netwo...

Page 22: ...header file if_fddi h If you are writing the network driver for Token Ring media you also include the header file if_trn h 4 Includes the devdriver h header file which defines common device driver dat...

Page 23: ...ocked struct el_softc struct ifnet int static int el_init int static void el_start_locked struct el_softc struct ifnet static void el_start struct ifnet static int el_watch int static void el_reset_lo...

Page 24: ...struct controller el_info el_MAXDEV 0 3 static int el_isa_tag 0 4 static int el_isa_reset 0 5 decl_simple_lock_info static el_lock_info 6 1 Defines a constant called el_MAXDEV which allocates data str...

Page 25: ...he if_el driver initializes the following members to nonzero values probe which specifies the driver s probe interface el_probe cattach which specifies the driver s controller attach interface el_atta...

Page 26: ...fine READ_STS sc READ_BUS_D16 sc regE mb define WRITE_DATA sc val WRITE_BUS_D32 sc data val mb define READ_DATA sc READ_BUS_D32 sc data mb define READ_ND sc READ_BUS_D16 sc reg6 mb define WRITE_ND sc...

Page 27: ...on control register READ_ACR and WRITE_ACR Read from and write to the 3Com 3C5x9 device s address control register WRITE_RCR Write to the 3Com 3C5x9 device s resource configuration register WRITE_ECR...

Page 28: ...ation support section for a network device driver contains the following entry points A probe interface which determines if the network device exists and is functional on the system An attach interfac...

Page 29: ...to do with data packet transmission and reception Typically these tasks relate to turning specific features of the hardware on or off The ioctl section contains an ioctl interface You define this entr...

Page 30: ...interface to transmit the data All network drivers must set the output member of the ifnet data structure to ether_output 1 12 Network Device Driver Environment...

Page 31: ...registers However this device register header file can serve as an example of how to set up device register offset definitions See your network device documentation to learn about control and status r...

Page 32: ..._WINDOW0 0x1 11 0x0 3 define CMD_WINDOW1 0x1 11 0x1 4 define CMD_WINDOW2 0x1 11 0x2 5 define CMD_WINDOW3 0x1 11 0x3 6 define CMD_WINDOW4 0x1 11 0x4 7 define CMD_WINDOW5 0x1 11 0x5 8 define CMD_WINDOW6...

Page 33: ...stic purposes 8 Defines a second window selector for commands that are used for diagnostic purposes 9 Defines the window selector for commands that are related to gathering device statistics 10 Define...

Page 34: ...ines the transmit TX start threshold command 27 Defines the statistics enable command 28 Defines the statistics disable command 29 Defines the stop 10Base2 Ethernet cable command 30 Defines the receiv...

Page 35: ...ters that make up the window 0 configuration register define W0_MID 0x0 1 define W0_AID 0x2 2 define W0_CCR 0x4 3 enum w0_ccr 4 CCR_PCMCIA 0x4000 CCR_AUI 0x2000 CCR_10B2 0x1000 CCR_ENDEC 0x0100 CCR_RE...

Page 36: ...r 5 Defines the offset for the address control register 6 Defines an enumerated data type called w0_acr The if_el device driver can assign one of the following values to W0_ACR the address control reg...

Page 37: ...that the EEPROM is in test mode ECR_CMD Represents EEPROM command bits ECR_READ Represents an EEPROM read command ECR_WRITE Represents an EEPROM write command ECR_ERASE Represents an EEPROM erase com...

Page 38: ...0000002 1 Defines the offset for the additional setup information register 2 2 Defines the offset for the additional setup information register 0 3 Defines an enumerated data type called w3_asi The if...

Page 39: ...W1_RXSTAT Transmit Status Register W1_TXSTAT Request Interrupt After Transmit Completion Register TX_INT Receive Data Register W1_RXDATA Transmit Data Register W1_TXDATA Free Transmit Bytes Register...

Page 40: ...BYTES Mask used to determine the number of bytes received 3 Defines the offset for the transmit status register 4 Defines an enumerated data type called w1_txstat The if_el device driver can assign on...

Page 41: ...W4_NET The following code shows the definitions for the window 4 diagnostic registers define W4_MEDIA 0xa 1 enum w4_media 2 MD_TPE 0x8000 MD_COAXE 0x4000 MD_RES1 0x2000 MD_SQE 0x1000 MD_VLB 0x0800 MD...

Page 42: ...ed MD_COLL Indicates that collisions occurred MD_SQEE Indicates that SQE stats were enabled MD_NCRC Indicates that the CRC strip was disabled 3 Defines the offset for the network diagnostic port regis...

Page 43: ...M data structure called w3_eeprom This data structure has the following members addr Contains the local area network LAN address pid Contains the product ID mandata Contains manufacturing data mid Con...

Page 44: ......

Page 45: ...tion 3 4 Multicast table information Section 3 5 Interrupt handler ID declaration Section 3 6 CSR pointer information Section 3 7 FIFO maintenance information Section 3 8 Bus specific information Sect...

Page 46: ...e drivers provide in the associated softc data structure and a double asterisk denotes information that is specific to the hardware or bus 3 1 Defining Common Information The common information in a l...

Page 47: ...tructure to the alternate name ctrblk The ess_ctrblk member is referred to as the counter block and is actually an instance of the estat data structure Figure 3 2 shows the ctrblk alternate name and a...

Page 48: ...for defining and exporting these attributes To use these routines a network driver must declare a net_hw_mgmt data structure as shown by the following code struct net_hw_mgmt ehm 1 1 Declares a net_hw...

Page 49: ...ENSE The hardware determines the media 3 Defines an alternate name for referencing the lan_media_state member of the lan_media data structure The lan_media_state member will be set only if lan_media_m...

Page 50: ...f_el device driver s el_softc data structure Most network device drivers declare this data structure in their softc data structure struct lan_multi is_multi 1 1 Declares a lan_multi data structure and...

Page 51: ...value that the device keeps on board The following code shows its declaration This information is hardware specific so you can omit it from your network device driver s softc data structure unsigned...

Page 52: ...ver and therefore is optional in most network device drivers The following code shows the declaration of the broadcast flag in the if_el device driver s el_softc data structure int is_broadcast 1 1 Co...

Page 53: ...utosense kernel thread variables in the if_el device driver s el_softc data structure The if_el device driver uses kernel threads to perform the tasks that are related to autosensing the media However...

Page 54: ...ata structure contains the declaration of a simple lock data structure The if_el driver uses a simple lock to protect the data integrity of the el_softc data structure on multiprocessor systems It als...

Page 55: ...led lan_configure Routines with the prefix lan_ reside in the lan_common c source file A network driver s configure routine can simply call lan_configure to carry out the following tasks CFG_OP_CONFIG...

Page 56: ...array is where the cfgmgr framework stores the value for the PCMCIA_Option attribute The cfgmgr framework obtains this value from the etc sysconfigtab database 2 Declares a character array called isa...

Page 57: ..._Per_Second attribute which is specific to this device driver It indicates the polls per second for interrupt processing Similar to the Polling attribute you can only specify a value for this attribut...

Page 58: ...luded in indata 4 Declares an argument for user defined configuration operations which can occur when the cfgmgr framework calls the driver s configure interface with the CFG_OP_USERDEFINED operation...

Page 59: ...evice driver kit The following sections describe how to use the probe interface Implementing the el_probe routine Section 5 1 Implementing the el_shutdown routine Section 5 2 Implementing the el_autos...

Page 60: ...vice register or memory that is located in bus address space either I O space or memory space This I O handle references the device s I O address space for the bus where the read operation originates...

Page 61: ...2 8 Declares a variable called reg that stores the I O handle that is passed to the driver s el_probe routine 9 Declares an e_port data structure called port_sel This data structure is associated with...

Page 62: ...ntrollers that the if_el driver can support 2 Returns the value 0 zero to indicate that the probe operation failed 5 1 3 Performing Bus Specific Tasks The following code shows how the el_probe routine...

Page 63: ...ociated with this 3Com 3C5x9 device 2 Performs tasks related to the PCMCIA bus if bus_type evaluates to the constant BUS_PCMCIA 3 Adds the I O handle to the base address of the card and stores it in t...

Page 64: ...em calls the el_isa_reset_all routine to reset all 3Com 3C5x9 adapters on the ISA bus once to clear any bad state data 14 Calls the el_isa_activate routine to attempt to activate the lowest addressed...

Page 65: ...user did not remove and replace the card calls the MALLOC macro to allocate memory for the el_softc data structure 3 If MALLOC could not allocate the memory calls the printf routine to display an appr...

Page 66: ...regC reg 0xc 2 sc regA reg 0xa sc reg8 reg 0x8 sc reg6 reg 0x6 sc reg4 reg 0x4 sc reg2 reg 0x2 sc reg0 reg 0x0 sc data reg 0x0 sc basereg reg 3 1 Fills in the regE member of the el_softc data structu...

Page 67: ...evaluates to BUS_PCMCIA 3 Sets the interrupt request IRQ to the value 3 4 Sets the I O base of the program card to the value 0 zero 5 Indicates that this is a PCMCIA unit and saves the card informatio...

Page 68: ...le tuple_infop if status SUCCESS tuple_data_infop TupleOffset 0 tuple_data_infop TupleDataMax u_short TUPLE_DATA_MAX status GetTupleData tuple_data_infop if status SUCCESS ee unsigned char sc eeprom f...

Page 69: ...oes not need to redo much of the initial probe work and will skip to the code shown in Section 5 1 10 2 If this is a multifunction card reads the EEPROM data and saves it in sc eeprom If this is a mul...

Page 70: ...ice 12 Frees up any memory that was allocated for enhanced hardware management and unregisters this card from the hardware management database 13 Calls the FREE macro which frees the memory that was p...

Page 71: ...ove return 0 else 2 ed unsigned short ee_copy for i 0 i sizeof struct w3_eeprom 2 i WRITE_ECR sc ECR_READ i DELAY 1000 ed READ_EDR sc ed if bcmp sc eeprom addr ee_copy addr 6 3 for i 0 i 3 i 4 j sc ee...

Page 72: ...e hardware address that is currently in effect uses the hardware address that was found in the EEPROM Because the EEPROM has changed because the old if_el adapter was removed and a new one inserted it...

Page 73: ...ucture to el_intr which is the if_el device driver s interrupt handler 3 Sets the param member of the el_intr_info data structure to the controller number for the controller data structure for this 3C...

Page 74: ...for this instance of the 3Com 3C5x9 device in the array of el_softc data structures The unit number is the offset to the data structure within the el_softc array 2 Saves the controller data structure...

Page 75: ...ws static void el_shutdown struct el_softc sc 1 WRITE_CMD sc CMD_RESET 2 DELAY 1000 3 1 Specifies the argument that the kernel passes to the routine which is a pointer to the driver s el_softc data st...

Page 76: ...dia is thin wire LAN_MEDIA_AUI The media is the attachment unit interface AUI The lm_media_state member specifies the current state of the autosensing procedure as follows LAN_MEDIA_STATE_SENSING The...

Page 77: ...the message to transmit when trying to determine the mode of the device 2 Declares a pointer to the el_softc data structure and calls it sc 3 Declares a pointer to an ifnet data structure and calls it...

Page 78: ...ling the thread_halt_self routine The thread_halt_self routine does not return to the caller 5 3 4 Starting Up Statistics The following code shows how the el_autosense_thread routine starts up statist...

Page 79: ..._PASSES m NULL if m m_freem m printf el d Autosense thread cannot determine media n ifp if_unit printf el d Use lan_config to configure if necessary n ifp if_unit else printf el d Autosense thread can...

Page 80: ...the el_autosense_thread routine builds a test packet to transmit bcopy el_junk_msg mtod m caddr_t EL_JUNK_SIZE 1 bcopy sc is_addr mtod m caddr_t 6 2 bcopy sc is_addr mtod m caddr_t 6 6 3 m m_pkthdr le...

Page 81: ...thread_block 5 3 13 Testing for Loss of Carrier The following code shows how the el_autosense_thread routine tests for loss of carrier link_beat 0 1 switch sc lm_media case LAN_MEDIA_UTP s splimp simp...

Page 82: ...ines whether traffic went out successfully 5 3 15 Printing Debug Information The following code shows how the el_autosense_thread routine prints debug information if sc debug 1 if prev_err ifp if_oerr...

Page 83: ...d Autosense selected s media n ifp if_unit lan_media_strings_10 sc lm_media s splimp 2 simple_lock sc el_softc_lock 3 WRITE_CMD sc CMD_STATSDIS 4 simple_unlock sc el_softc_lock 5 splx s 6 1 Sets the l...

Page 84: ...l_simple_lock_data routine 4 Calls the WRITE_CMD macro to write data to the command port register In this call el_autosense_thread passes the if_el driver s el_softc data structure pointer The data to...

Page 85: ...ssage Section 6 5 Specifies the network driver interfaces Section 6 6 Sets the baud rate Section 6 7 Attaches to the packet filter and the network layer Section 6 8 Sets network attributes and registe...

Page 86: ...called sin 6 2 Initializing the Media Address and Media Header Lengths The el_attach routine sets up the media s address length and header length as follows if sc reprobe 1 ctlr alive ALV_STATIC 2 if...

Page 87: ...addr 7 sin sin_family AF_INET 8 1 Sets the ac_bcastaddr member of the softc data structure for this device to the Ethernet broadcast address The system stores the Ethernet broadcast address in the eth...

Page 88: ...for this device to the maximum transmission unit for the media which for Ethernet related media is represented by the constant ETHERMTU Typically you set this member to the same constant that is used...

Page 89: ...execute on a single the master CPU This setting is not recommended You are encouraged to make your driver SMP safe NETALLCPU Specifies that you do not want to funnel the network device driver because...

Page 90: ...er_sprintf routine The ether_sprintf routine converts an Ethernet address to a printable ASCII string representation Make sure that your driver prints a similar message during its attach routine 6 6 S...

Page 91: ...ies that the network interface supports broadcasting and that the associated broadcast address is valid IFF_MULTICAST Signifies that the network interface supports multicast IFF_NOTRAILERS Signifies t...

Page 92: ...THER_BAND WIDTH_100MB constant FDDI_BANDWIDTH_100MB FDDI line speed is 100 megabits per second The if_fddi h file defines the FDDI_BANDWIDTH_100MB constant TRN_BANDWIDTH_4MB Token Ring line speed is 4...

Page 93: ...2 Registers the adapter with EHM 6 10 Handling the Reinsert Operation If the user has reinserted the PCMCIA card the if_el device driver does not need to initialize the media address and media length...

Page 94: ...g_flag 0 2 return 0 1 Starts the polling process if the el_polling attribute specifies that polling is to be done To start the polling process el_attach sets the polling_flag member to 1 true then cal...

Page 95: ...wn Section 7 2 Obtains and releases the simple lock Section 7 3 Disables the interrupt handler Section 7 4 Terminates the autosense thread Section 7 5 Unregisters the PCMCIA event callback routine Sec...

Page 96: ...Make sure that other errors returned by if_detach do not stop interface shutdown status if_detach ifp 1 if status EBUSY 2 return status else if status ESUCCESS 3 detachpfilter sc is_ed ifp if_flags I...

Page 97: ...Calls the splx routine to reset the CPU priority to the level that is stored in the s variable 7 4 Disabling the Interrupt Handler The following code shows how the el_unattach routine disables and de...

Page 98: ...void ifp if_unit 2 sc polling_flag 0 3 simple_unlock sc el_softc_lock splx s 1 Stops the polling process if polling had originally been requested by the user 2 Removes the scheduled event from the sys...

Page 99: ...management and unregisters this card from the hardware management database 7 11 Freeing Resources The following code shows how the el_unattach routine frees data structures and memory that the adapter...

Page 100: ......

Page 101: ...orm the initialization Section 8 1 4 Releases the simple lock and resets the IPL Section 8 1 5 Returns the status from el_init_locked Section 8 1 6 8 1 1 Setting Up the el_init Routine The following c...

Page 102: ...the Simple Lock All network device drivers must set the interrupt priority level IPL to mask all LAN hardware interrupts Raising the IPL protects the driver from interrupts on the same CPU Only networ...

Page 103: ...easing the simple lock simple_unlock sc el_softc_lock 1 splx s 2 1 Calls the simple_unlock routine to release the simple lock 2 Calls the splx routine to reset the CPU priority to the level that is st...

Page 104: ...the 3Com 3C5x9 device Make sure that you perform similar initialization tasks for the hardware device that your network driver controls static int el_init_locked struct el_softc sc struct ifnet ifp in...

Page 105: ...s configuration control register The data to be written consists of the original register contents but with the enable adapter bit CCR_ENA set 2 Calls the WRITE_RCR macro to write data to the 3Com 3C5...

Page 106: ...CR_BASE the I O base address and the ACR_10B2 Ethernet thin coaxial cable bits 3 Evaluates the value that is stored in the lm_media member of the el_softc data structure for this device 4 Determines w...

Page 107: ...lan_set_attribute sc ehm current_val NET_MEDIA_NDX lan_media_strings sc lm_media 1 1 Sets the LAN media type attribute for EHM support 8 2 7 Selecting Memory Mapping The following code shows how the e...

Page 108: ...ddr 5 8 sc is_addr 4 WRITE_AD3 sc i lan_set_attribute sc ehm current_val NET_MAC_NDX ether_sprintf sc is_addr 2 1 Performs several write operations to set the LAN address 2 Sets the LAN MAC address at...

Page 109: ...and CMD_FILTER with the appropriate flags set 8 2 11 Setting the Debug Flag The following code shows how the el_init_locked routine sets the debug flag for turning on debugging on a running system Thi...

Page 110: ...MD_ZINTMASK 0xfe WRITE_CMD sc CMD_SINTMASK S_AF S_TC S_RC else 2 WRITE_CMD sc CMD_ZINTMASK 0xfe WRITE_CMD sc CMD_SINTMASK 0 1 If the device is not polling the el_polling flag is not set calls the WRIT...

Page 111: ...ad_wakeup_one vm_offset_t sc autosense_flag 1 If in autosense mode starts the autosense kernel thread 8 2 17 Starting the Transmit of Pending Packets The following code shows how the el_init_locked ro...

Page 112: ......

Page 113: ...a jacket routine that performs the following tasks Sets the IPL and obtains the simple lock Section 9 1 1 Calls the el_start_locked routine Section 9 1 2 Releases the simple lock and resets the IPL Se...

Page 114: ...n to the caller The argument to simple_lock_try is a pointer to a simple lock data structure The if_el device driver declares the simple lock data structure by calling the decl_simple_lock_data routin...

Page 115: ...ets Section 9 2 3 Accounts for the outgoing bytes Section 9 2 4 Updates counters frees the transmit buffer and marks the output process as active Section 9 2 5 Indicates when to start the watchdog int...

Page 116: ...mber of the ifnet data structure for this device The memory buffer information that IF_DEQUEUE manipulates is specified in the instance of the mbuf data structure called m 4 As long as a transmit requ...

Page 117: ...the chain of mbuf data structures in the ms mbuf pointer The m_next member stores the next memory buffer in the chain Network device drivers typically reference this member through the alternate name...

Page 118: ...ar len ms m_len while ms NULL io_blockwrite vm_offset_t dat 2 sc data u_long len 3 HANDLE_LONGWORD dat len 3 ms ms m_next i len 4 3 if ms NULL if i val 0 for j 0 j i j val dat 8 j WRITE_DATA sc val el...

Page 119: ...r and Marking the Output Process as Active The following code shows how the el_start_locked routine updates counters frees the transmit buffer and marks the output process as active ADD_XMIT_PACKET if...

Page 120: ...lthough this task is optional we recommend that all network drivers perform this task ifp if_timer 3 1 1 Sets the time in seconds for starting the if_el driver s watchdog routine called el_watch After...

Page 121: ...The watchdog section of a network device driver is an optional interface but we recommend that all network drivers have one The if_el device driver implements a watchdog routine called el_watch which...

Page 122: ...t Timeout Counter and Resetting the Unit The following code shows how the el_watch routine counts the number of transmit timeouts clears the timer and resets the unit sc xmit_tmo 1 ifp if_timer 0 el_r...

Page 123: ...forms the following tasks Determines whether the user removes the PCMCIA card from the slot Sets the IPL and obtains the simple lock Calls the el_reset_locked routine to reset the device Releases the...

Page 124: ...mplementing the el_reset_locked Routine The following code shows how the el_reset_locked routine resets and restarts the hardware static void el_reset_locked struct el_softc sc struct ifnet ifp int un...

Page 125: ...able 12 1 lists the ioctl commands that network device drivers must recognize Releases the simple lock and resets the IPL Section 12 17 Table 12 1 Network ioctl Commands ioctl Command Required Descrip...

Page 126: ...gister unit ifp if_unit 5 struct ifreq ifr struct ifreq data 6 struct ifdevea ifd struct ifdevea data 7 struct ctrreq ctr struct ctrreq data 8 struct ifchar ifc struct ifchar data 9 int s i j need_res...

Page 127: ...use on the device 12 2 Determining Whether the User Has Removed the PCMCIA Card from the Slot The following code shows how the el_ioctl routine determines whether the user has removed the PCMCIA card...

Page 128: ...if_flags member of the ifnet data structure for this device 4 If the device is running calls the el_reset_locked routine to restart the network interface in loopback mode 12 5 Disabling Loopback Mode...

Page 129: ...C address that is stored in the driver s el_softc data structure for this device to the ifd data structure 12 7 Setting the Local MAC Address SIOCSPHYSADDR ioctl Command The following code shows how t...

Page 130: ...ink address 12 8 Adding the Device to a Multicast Group SIOCADDMULTI ioctl Command The following code shows how the el_ioctl routine implements the SIOCADDMULTI ioctl command to add a multicast addres...

Page 131: ...to be reset 4 If the device is running and multicasts and broadcasts have not already been enabled enables them 5 Builds a text string that lists all currently active multicast addresses and sets thi...

Page 132: ...ced hardware management EHM attribute for this network device 12 10 Accessing Network Counters SIOCRDCTRS and SIOCRDZCTRS ioctl Commands The SIOCRDCTRS ioctl command returns the values of network coun...

Page 133: ...the various network interfaces support Table 12 2 Network Interface Counter Types Network Interface Counter Types FDDI FDDI interface statistics Status information SMT attributes MAC attributes Path a...

Page 134: ...routine implements the SIOCSIPMTU ioctl command to set the IP MTU You must implement this task in your network driver to accommodate the IP layer case SIOCSIPMTU 1 bcopy ifr ifr_data u_char ifmtu siz...

Page 135: ...octl command to reset the device Support for the SIOCIFRESET command is optional You can choose whether or not your driver supports it case SIOCIFRESET 1 el_reset_locked sc ifp unit 2 break 1 Determin...

Page 136: ...IOCIFSETCHAR 2 Assumes no device reset is necessary 3 If the LAN speed passed is anything other than 10 1 means no change fails the request 4 Examines the media mode settings If the ioctl request spec...

Page 137: ...icates that the caller has issued an invalid ioctl command 12 17 Releasing the Simple Lock and Resetting the IPL The following code shows how the el_ioctl routine releases the simple lock and resets t...

Page 138: ......

Page 139: ...errupt framework that Tru64 UNIX provides for hardware devices that share an interrupt line The ISA bus does not currently support shared interrupts 13 1 Implementing the el_intr Routine The if_el dev...

Page 140: ...rrupts 4 Calls the simple_lock routine to assert a lock with exclusive access for the resource that is associated with el_softc_lock 13 1 2 Rearming the Next Timeout The following code shows how the e...

Page 141: ...S_RC bit the transmit complete S_TC bit or the adapter failure S_AF bit set or if the PCMCIA card is out of the slot Calls the simple_unlock routine to release the simple lock for the resource that is...

Page 142: ...he acknowledge interrupt CMD_ACKINT and interrupt latch S_IL bits specify the data to be written 13 1 6 Transmitting Pending Frames The following code shows how the el_intr routine transmits pending f...

Page 143: ...ines the first part of the packet Section 13 2 3 Copies the received packet into the mbuf Section 13 2 4 Discards a packet Section 13 2 5 13 2 1 Counting the Receive Interrupt and Reading the Receive...

Page 144: ...un 0xffff sc ctrblk est_overrun if sc debug printf el d Overrun n ifp if_unit break case RX_ERT 5 case RX_EOS sc ctrblk est_recvfail_bm 4 if sc debug printf el d Bad Sized packet n ifp if_unit break c...

Page 145: ...buf is allocated This code is an optimization In most cases a driver does not know the size of a receive packet when the buffer resource is allocated 13 2 3 Examining the First Part of the Packet The...

Page 146: ...r to the data and calculates the number of longwords in the FIFO transfer 5 Because the EtherLink III performs no multicast filtering if the promiscuous bit and all multicast bits are not set determin...

Page 147: ...stination address source address and ether_type fields 5 Calls the ADD_RECV_PACKET macro to increment the receive packet block count If this packet was destined for a broadcast or multicast address ca...

Page 148: ...obtain the next value Section 13 3 4 Queues other transmits Section 13 3 5 13 3 1 Counting the Transmit Interrupt The following code shows how the el_tint routine counts the transmit interrupt define...

Page 149: ...f_collisions 2 if sc ctrblk est_sendfail 0xffff sc ctrblk est_sendfail sc ctrblk est_sendfail_bm 1 2 WRITE_TXS sc status WRITE_CMD sc CMD_TXENA else 1 Increments the output errors because the excessiv...

Page 150: ...gs IFF_OACTIVE 13 4 Implementing the el_error Routine The if_el driver s el_error routine implements the interface adapter error routine as follows static void el_error struct el_softc sc struct ifnet...

Page 151: ...etc sysconfigtab database when the driver is installed The startup procedure and the sysconfig utility use the information that the etc sysconfigtab database provides to locate the driver module and...

Page 152: ......

Page 153: ...itting 9 6 bus specific information 3 7 initializing 5 8 C carrier checking for transmits 5 23 cfg_subsys_attr_t data structure 4 2 command port register definitions 2 2 common information el_softc da...

Page 154: ...utine 13 12 el_init_locked routine 8 3 calling in el_init 8 3 returning status from 8 3 el_intr routine 13 1 el_ioctl routine SIOCADDMULTI ioctl command 12 6 SIOCDELMULTI ioctl command 12 7 SIOCDISABL...

Page 155: ...device driver 1 5 F FIFO maintenance information 3 7 flag processing special 8 8 setting debug 8 9 using currently set 12 10 forward declarations if_el device driver 1 5 frames transmitting pending 13...

Page 156: ...l_watch 10 2 setting in el_init 8 2 in el_intr 13 2 in el_ioctl 12 3 in el_start 9 1 in el_watch 10 1 ISA bus initializing bus specific data structure 5 8 probing 5 4 K kernel thread blocking 5 19 set...

Page 157: ...8 11 packet filter attaching 6 8 packet transmit loop entering 5 20 PCI_Option entry sysconfigtab file fragment 14 1 PCMCIA bus discarding all transmits 9 3 initializing bus specific data structure 5...

Page 158: ...ng 3 10 SIOCADDMULTI ioctl command 12 6 SIOCDELMULTI ioctl command 12 7 SIOCDISABLBACK ioctl command 12 4 SIOCENABLBACK ioctl command 12 4 SIOCIFRESET ioctl command 12 11 SIOCIFSETCHAR ioctl command 1...

Page 159: ...smitter resetting 8 4 8 7 TX and RX enabling 8 9 U unattach interface 7 1 unit resetting 10 2 V VBA_Option entry sysconfigtab file fragment 14 1 W w3_eeprom data structure 2 13 in el_softc data struct...

Reviews: