Index: stable/4/sys/conf/files.i386 =================================================================== --- stable/4/sys/conf/files.i386 (revision 98399) +++ stable/4/sys/conf/files.i386 (revision 98400) @@ -1,489 +1,488 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # # $FreeBSD$ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # linux_genassym.o optional compat_linux \ dependency "$S/i386/linux/linux_genassym.c" \ compile-with "${CC} ${CFLAGS} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "linux_genassym.o" # svr4_genassym.o optional compat_svr4 \ dependency "$S/i386/svr4/svr4_genassym.c" \ compile-with "${CC} ${CFLAGS} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "svr4_genassym.o" # linux_assym.h optional compat_linux \ dependency "$S/kern/genassym.sh linux_genassym.o" \ compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # svr4_assym.h optional compat_svr4 \ dependency "$S/kern/genassym.sh svr4_genassym.o" \ compile-with "sh $S/kern/genassym.sh svr4_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "svr4_assym.h" # font.h optional sc_dflt_font \ compile-with "uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'static u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'static u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'static u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \ no-obj no-implicit-rule before-depend \ clean "font.h" # atkbdmap.h optional atkbd_dflt_keymap \ compile-with "/usr/sbin/kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "atkbdmap.h" # ukbdmap.h optional ukbd_dflt_keymap \ compile-with "/usr/sbin/kbdcontrol -L ${UKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > ukbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # compat/linux/linux_file.c optional compat_linux compat/linux/linux_getcwd.c optional compat_linux compat/linux/linux_ioctl.c optional compat_linux compat/linux/linux_ipc.c optional compat_linux compat/linux/linux_mib.c optional compat_linux compat/linux/linux_misc.c optional compat_linux compat/linux/linux_signal.c optional compat_linux compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux # contrib/dev/fla/fla.c optional fla msysosak.o optional fla \ dependency "$S/contrib/dev/fla/i386/msysosak.o.uu" \ compile-with "uudecode < $S/contrib/dev/fla/i386/msysosak.o.uu" \ no-implicit-rule # contrib/dev/oltr/if_oltr.c optional oltr trlld.o optional oltr \ dependency "$S/contrib/dev/oltr/i386${FMT}.trlld.o.uu" \ compile-with "uudecode < $S/contrib/dev/oltr/i386${FMT}.trlld.o.uu" \ no-implicit-rule contrib/dev/oltr/trlldbm.c optional oltr contrib/dev/oltr/trlldhm.c optional oltr contrib/dev/oltr/trlldmac.c optional oltr bf_enc.o optional ipsec ipsec_esp \ dependency "$S/crypto/blowfish/arch/i386/bf_enc.S $S/crypto/blowfish/arch/i386/bf_enc_586.S $S/crypto/blowfish/arch/i386/bf_enc_686.S" \ compile-with "${CC} -c -I$S/crypto/blowfish/arch/i386 ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}" \ no-implicit-rule crypto/des/arch/i386/des_enc.S optional ipsec ipsec_esp crypto/des/des_ecb.c optional netsmbcrypto crypto/des/arch/i386/des_enc.S optional netsmbcrypto crypto/des/des_setkey.c optional netsmbcrypto dev/advansys/adv_isa.c optional adv isa dev/aic/aic_isa.c optional aic isa dev/ar/if_ar_isa.c optional ar isa dev/dgb/dgm.c optional dgm dev/cm/if_cm_isa.c optional cm isa dev/ed/if_ed.c optional ed dev/ed/if_ed_isa.c optional ed isa dev/ed/if_ed_pccard.c optional ed card dev/eisa/eisaconf.c optional eisa dev/em/if_em.c optional em -dev/em/if_em_fxhw.c optional em -dev/em/if_em_phy.c optional em +dev/em/if_em_hw.c optional em dev/fb/fb.c optional fb dev/fb/fb.c optional vga dev/fb/splash.c optional splash dev/fb/vga.c optional vga dev/fe/if_fe_isa.c optional fe isa dev/kbd/atkbd.c optional atkbd dev/kbd/atkbdc.c optional atkbdc dev/kbd/kbd.c optional atkbd dev/kbd/kbd.c optional kbd dev/kbd/kbd.c optional sc dev/kbd/kbd.c optional ukbd dev/kbd/kbd.c optional vt dev/puc/puc.c optional puc dev/puc/pucdata.c optional puc dev/sbni/if_sbni.c optional sbni dev/sbni/if_sbni_isa.c optional sbni isa dev/syscons/schistory.c optional sc dev/syscons/scmouse.c optional sc dev/syscons/scterm.c optional sc dev/syscons/scterm-dumb.c optional sc dev/syscons/scterm-sc.c optional sc dev/syscons/scvesactl.c optional sc vga vesa dev/syscons/scvgarndr.c optional sc vga dev/syscons/scvidctl.c optional sc dev/syscons/scvtb.c optional sc dev/syscons/syscons.c optional sc dev/syscons/sysmouse.c optional sc fs/smbfs/smbfs_io.c optional smbfs fs/smbfs/smbfs_node.c optional smbfs fs/smbfs/smbfs_smb.c optional smbfs fs/smbfs/smbfs_subr.c optional smbfs fs/smbfs/smbfs_vfsops.c optional smbfs fs/smbfs/smbfs_vnops.c optional smbfs gnu/i386/fpemul/div_small.s optional gpl_math_emulate gnu/i386/fpemul/errors.c optional gpl_math_emulate gnu/i386/fpemul/fpu_arith.c optional gpl_math_emulate gnu/i386/fpemul/fpu_aux.c optional gpl_math_emulate gnu/i386/fpemul/fpu_entry.c optional gpl_math_emulate gnu/i386/fpemul/fpu_etc.c optional gpl_math_emulate gnu/i386/fpemul/fpu_trig.c optional gpl_math_emulate gnu/i386/fpemul/get_address.c optional gpl_math_emulate gnu/i386/fpemul/load_store.c optional gpl_math_emulate gnu/i386/fpemul/poly_2xm1.c optional gpl_math_emulate gnu/i386/fpemul/poly_atan.c optional gpl_math_emulate gnu/i386/fpemul/poly_div.s optional gpl_math_emulate gnu/i386/fpemul/poly_l2.c optional gpl_math_emulate gnu/i386/fpemul/poly_mul64.s optional gpl_math_emulate gnu/i386/fpemul/poly_sin.c optional gpl_math_emulate gnu/i386/fpemul/poly_tan.c optional gpl_math_emulate gnu/i386/fpemul/polynomial.s optional gpl_math_emulate gnu/i386/fpemul/reg_add_sub.c optional gpl_math_emulate gnu/i386/fpemul/reg_compare.c optional gpl_math_emulate gnu/i386/fpemul/reg_constant.c optional gpl_math_emulate gnu/i386/fpemul/reg_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_ld_str.c optional gpl_math_emulate gnu/i386/fpemul/reg_mul.c optional gpl_math_emulate gnu/i386/fpemul/reg_norm.s optional gpl_math_emulate gnu/i386/fpemul/reg_round.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_add.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_mul.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_sub.s optional gpl_math_emulate gnu/i386/fpemul/wm_shrx.s optional gpl_math_emulate gnu/i386/fpemul/wm_sqrt.s optional gpl_math_emulate gnu/i386/isa/dgb.c optional dgb gnu/i386/isa/sound/awe_wave.c optional awe i386/apm/apm.c optional apm i386/i386/atomic.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}" i386/i386/autoconf.c standard i386/i386/bios.c standard i386/i386/bioscall.s standard i386/i386/busdma_machdep.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb i386/i386/elf_machdep.c standard i386/i386/exception.s standard i386/i386/globals.s standard i386/i386/i386-gdbstub.c optional ddb i386/i386/i686_mem.c standard i386/i386/identcpu.c standard i386/i386/in_cksum.c optional inet i386/i386/initcpu.c standard i386/i386/k6_mem.c standard # locore.s needs to be handled in Makefile to put it first. Otherwise it's # now normal. # i386/i386/locore.s standard i386/i386/machdep.c standard i386/i386/math_emulate.c optional math_emulate i386/i386/mem.c standard i386/i386/mp_clock.c optional smp i386/i386/mp_machdep.c optional smp i386/i386/mpapic.c optional smp i386/i386/mpboot.s optional smp i386/i386/mplock.s optional smp i386/i386/nexus.c standard i386/i386/perfmon.c optional perfmon i386/i386/perfmon.c optional perfmon profiling-routine i386/i386/pmap.c standard i386/i386/procfs_machdep.c standard i386/i386/simplelock.s optional smp i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard i386/i386/trap.c standard i386/i386/userconfig.c optional userconfig i386/i386/vm86.c standard i386/i386/vm_machdep.c standard i386/ibcs2/ibcs2_errno.c optional ibcs2 i386/ibcs2/ibcs2_fcntl.c optional ibcs2 i386/ibcs2/ibcs2_ioctl.c optional ibcs2 i386/ibcs2/ibcs2_ipc.c optional ibcs2 i386/ibcs2/ibcs2_isc.c optional ibcs2 i386/ibcs2/ibcs2_isc_sysent.c optional ibcs2 i386/ibcs2/ibcs2_misc.c optional ibcs2 i386/ibcs2/ibcs2_msg.c optional ibcs2 i386/ibcs2/ibcs2_other.c optional ibcs2 i386/ibcs2/ibcs2_signal.c optional ibcs2 i386/ibcs2/ibcs2_socksys.c optional ibcs2 i386/ibcs2/ibcs2_stat.c optional ibcs2 i386/ibcs2/ibcs2_sysent.c optional ibcs2 i386/ibcs2/ibcs2_sysi86.c optional ibcs2 i386/ibcs2/ibcs2_sysvec.c optional ibcs2 i386/ibcs2/ibcs2_util.c optional ibcs2 i386/ibcs2/ibcs2_xenix.c optional ibcs2 i386/ibcs2/ibcs2_xenix_sysent.c optional ibcs2 i386/ibcs2/imgact_coff.c optional ibcs2 i386/isa/asc.c optional asc i386/isa/atapi.c optional wdc \ warning "The wdc driver is obsolete. Please use the ata driver!" i386/isa/clock.c standard i386/isa/cronyx.c optional cx i386/isa/ctx.c optional ctx i386/isa/cx.c optional cx i386/isa/cy.c optional cy i386/isa/elink.c optional ep i386/isa/elink.c optional ie isa/fd.c optional fd i386/isa/gpib.c optional gp i386/isa/gsc.c optional gsc i386/isa/if_cx.c optional cx i386/isa/if_el.c optional el i386/isa/if_le.c optional le i386/isa/if_lnc.c optional lnc i386/isa/if_rdp.c optional rdp i386/isa/if_sr.c optional sr i386/isa/if_wl.c optional wl i386/isa/if_wlp.c optional wlp i386/isa/intr_machdep.c standard i386/isa/ipl_funcs.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}" i386/isa/isa.c optional isa i386/isa/isa_compat.c optional isa i386/isa/isa_dma.c optional isa i386/isa/istallion.c optional stli i386/isa/labpc.c optional labpc i386/isa/loran.c optional loran i386/isa/matcd/matcd.c optional matcd i386/isa/mca_machdep.c optional mca i386/isa/mcd.c optional mcd i386/isa/mse.c optional mse i386/isa/npx.c mandatory npx i386/isa/pcaudio.c optional pca i386/isa/pcf.c optional pcf i386/isa/pci_cfgreg.c optional pci i386/isa/pcibus.c optional pci i386/isa/pcvt/pcvt_drv.c optional vt i386/isa/pcvt/pcvt_ext.c optional vt i386/isa/pcvt/pcvt_kbd.c optional vt i386/isa/pcvt/pcvt_out.c optional vt i386/isa/pcvt/pcvt_sup.c optional vt i386/isa/pcvt/pcvt_vtf.c optional vt i386/isa/prof_machdep.c optional profiling-routine i386/isa/rc.c optional rc i386/isa/rp.c optional rp i386/isa/scd.c optional scd i386/isa/sound/ad1848.c optional css i386/isa/sound/ad1848.c optional gus i386/isa/sound/ad1848.c optional gusxvi i386/isa/sound/ad1848.c optional mss i386/isa/sound/ad1848.c optional sscape i386/isa/sound/ad1848.c optional trix i386/isa/sound/ad1848.c optional sscape_mss i386/isa/sound/adlib_card.c optional opl i386/isa/sound/adlib_card.c optional trix i386/isa/sound/audio.c optional snd \ warning "The snd drivers are deprecated. Please see pcm/sbc/etc." i386/isa/sound/cs4232.c optional css i386/isa/sound/dev_table.c optional snd i386/isa/sound/dmabuf.c optional snd i386/isa/sound/gus_card.c optional gus i386/isa/sound/gus_midi.c optional gus i386/isa/sound/gus_vol.c optional gus i386/isa/sound/gus_wave.c optional gus i386/isa/sound/ics2101.c optional gus i386/isa/sound/midi_synth.c optional css i386/isa/sound/midi_synth.c optional gus i386/isa/sound/midi_synth.c optional mpu i386/isa/sound/midi_synth.c optional mss i386/isa/sound/midi_synth.c optional pas i386/isa/sound/midi_synth.c optional sb i386/isa/sound/midi_synth.c optional sscape i386/isa/sound/midi_synth.c optional uart i386/isa/sound/midibuf.c optional css i386/isa/sound/midibuf.c optional gus i386/isa/sound/midibuf.c optional mpu i386/isa/sound/midibuf.c optional mss i386/isa/sound/midibuf.c optional pas i386/isa/sound/midibuf.c optional sb i386/isa/sound/midibuf.c optional sscape i386/isa/sound/midibuf.c optional uart i386/isa/sound/mpu401.c optional mpu i386/isa/sound/mpu401.c optional sscape i386/isa/sound/opl3.c optional opl i386/isa/sound/opl3.c optional trix i386/isa/sound/pas2_card.c optional pas i386/isa/sound/pas2_midi.c optional pas i386/isa/sound/pas2_mixer.c optional pas i386/isa/sound/pas2_pcm.c optional pas i386/isa/sound/patmgr.c optional snd i386/isa/sound/sb16_dsp.c optional sbxvi i386/isa/sound/sb16_midi.c optional sbmidi i386/isa/sound/sb_card.c optional sb i386/isa/sound/sb_dsp.c optional sb i386/isa/sound/sb_midi.c optional sb i386/isa/sound/sb_mixer.c optional sb i386/isa/sound/sequencer.c optional snd i386/isa/sound/sound_switch.c optional snd i386/isa/sound/sound_timer.c optional css i386/isa/sound/sound_timer.c optional gus i386/isa/sound/sound_timer.c optional mss i386/isa/sound/sound_timer.c optional mss i386/isa/sound/sound_timer.c optional sscape i386/isa/sound/sound_timer.c optional trix i386/isa/sound/soundcard.c optional snd i386/isa/sound/sscape.c optional sscape i386/isa/sound/sys_timer.c optional snd i386/isa/sound/trix.c optional trix i386/isa/sound/uart6850.c optional uart i386/isa/spic.c optional spic i386/isa/spigot.c optional spigot i386/isa/spkr.c optional speaker i386/isa/stallion.c optional stl i386/isa/tw.c optional tw i386/isa/vesa.c optional vga vesa i386/isa/wd.c optional wd \ warning "The wd driver is obsolete. Please use the atadisk driver!" i386/isa/wd.c optional wdc i386/isa/wd_cd.c optional wcd wdc \ warning "The wcd driver is obsolete. Please use the atapicd driver!" i386/isa/wfd.c optional wfd wdc \ warning "The wfd driver is obsolete. Please use the atapifd driver!" i386/isa/wst.c optional wst wdc \ warning "The wst driver is obsolete. Please use the atapist driver!" i386/isa/wt.c optional wt i386/linux/imgact_linux.c optional compat_linux i386/linux/linux_dummy.c optional compat_linux i386/linux/linux_locore.s optional compat_linux \ dependency "linux_assym.h" i386/linux/linux_machdep.c optional compat_linux i386/linux/linux_sysent.c optional compat_linux i386/linux/linux_sysvec.c optional compat_linux svr4/imgact_svr4.c optional compat_svr4 svr4/svr4_fcntl.c optional compat_svr4 svr4/svr4_filio.c optional compat_svr4 svr4/svr4_ioctl.c optional compat_svr4 svr4/svr4_ipc.c optional compat_svr4 svr4/svr4_misc.c optional compat_svr4 svr4/svr4_resource.c optional compat_svr4 svr4/svr4_signal.c optional compat_svr4 svr4/svr4_socket.c optional compat_svr4 svr4/svr4_sockio.c optional compat_svr4 svr4/svr4_stat.c optional compat_svr4 svr4/svr4_stream.c optional compat_svr4 svr4/svr4_syscallnames.c optional compat_svr4 svr4/svr4_sysent.c optional compat_svr4 svr4/svr4_sysvec.c optional compat_svr4 svr4/svr4_termios.c optional compat_svr4 svr4/svr4_ttold.c optional compat_svr4 i386/svr4/svr4_locore.s optional compat_svr4 \ dependency "svr4_assym.h" i386/svr4/svr4_machdep.c optional compat_svr4 # # isdn4bsd, needed for isic | iwic | ifpi | | ifpi2 | ihfc | ifpnp | itjc # i4b/layer1/i4b_l1dmux.c optional isic i4b/layer1/i4b_l1lib.c optional isic i4b/layer1/i4b_l1dmux.c optional iwic i4b/layer1/i4b_l1lib.c optional iwic i4b/layer1/i4b_l1dmux.c optional ifpi i4b/layer1/i4b_l1lib.c optional ifpi i4b/layer1/i4b_l1dmux.c optional ifpi2 i4b/layer1/i4b_l1lib.c optional ifpi2 i4b/layer1/i4b_l1dmux.c optional ihfc i4b/layer1/i4b_l1lib.c optional ihfc i4b/layer1/i4b_l1dmux.c optional ifpnp i4b/layer1/i4b_l1lib.c optional ifpnp i4b/layer1/i4b_l1dmux.c optional itjc i4b/layer1/i4b_l1lib.c optional itjc # # isdn4bsd, isic # i4b/layer1/isic/i4b_asuscom_ipac.c optional isic i4b/layer1/isic/i4b_avm_a1.c optional isic i4b/layer1/isic/i4b_bchan.c optional isic i4b/layer1/isic/i4b_ctx_s0P.c optional isic i4b/layer1/isic/i4b_drn_ngo.c optional isic i4b/layer1/isic/i4b_dynalink.c optional isic i4b/layer1/isic/i4b_elsa_qs1i.c optional isic i4b/layer1/isic/i4b_elsa_qs1p.c optional isic i4b/layer1/isic/i4b_elsa_pcc16.c optional isic i4b/layer1/isic/i4b_hscx.c optional isic i4b/layer1/isic/i4b_isac.c optional isic i4b/layer1/isic/i4b_isic.c optional isic i4b/layer1/isic/i4b_isic_isa.c optional isic i4b/layer1/isic/i4b_isic_pnp.c optional isic i4b/layer1/isic/i4b_itk_ix1.c optional isic i4b/layer1/isic/i4b_l1.c optional isic i4b/layer1/isic/i4b_l1fsm.c optional isic i4b/layer1/isic/i4b_siemens_isurf.c optional isic i4b/layer1/isic/i4b_sws.c optional isic i4b/layer1/isic/i4b_tel_s016.c optional isic i4b/layer1/isic/i4b_tel_s0163.c optional isic i4b/layer1/isic/i4b_tel_s08.c optional isic i4b/layer1/isic/i4b_usr_sti.c optional isic i4b/layer1/isic/i4b_diva.c optional isic # # isdn4bsd, iwic # i4b/layer1/iwic/i4b_iwic_pci.c optional iwic i4b/layer1/iwic/i4b_iwic_dchan.c optional iwic i4b/layer1/iwic/i4b_iwic_bchan.c optional iwic i4b/layer1/iwic/i4b_iwic_fsm.c optional iwic i4b/layer1/iwic/i4b_iwic_l1if.c optional iwic # # isdn4bsd, ifpi # i4b/layer1/ifpi/i4b_ifpi_pci.c optional ifpi i4b/layer1/ifpi/i4b_ifpi_isac.c optional ifpi i4b/layer1/ifpi/i4b_ifpi_l1.c optional ifpi i4b/layer1/ifpi/i4b_ifpi_l1fsm.c optional ifpi # # isdn4bsd, ifpi2 # i4b/layer1/ifpi2/i4b_ifpi2_pci.c optional ifpi2 i4b/layer1/ifpi2/i4b_ifpi2_isacsx.c optional ifpi2 i4b/layer1/ifpi2/i4b_ifpi2_l1.c optional ifpi2 i4b/layer1/ifpi2/i4b_ifpi2_l1fsm.c optional ifpi2 # # isdn4bsd, ifpnp # i4b/layer1/ifpnp/i4b_ifpnp_avm.c optional ifpnp i4b/layer1/ifpnp/i4b_ifpnp_isac.c optional ifpnp i4b/layer1/ifpnp/i4b_ifpnp_l1.c optional ifpnp i4b/layer1/ifpnp/i4b_ifpnp_l1fsm.c optional ifpnp # # isdn4bsd, ihfc # i4b/layer1/ihfc/i4b_ihfc_l1if.c optional ihfc i4b/layer1/ihfc/i4b_ihfc_pnp.c optional ihfc i4b/layer1/ihfc/i4b_ihfc_drv.c optional ihfc # # isdn4bsd, itjc # i4b/layer1/itjc/i4b_itjc_pci.c optional itjc i4b/layer1/itjc/i4b_itjc_isac.c optional itjc i4b/layer1/itjc/i4b_itjc_l1.c optional itjc i4b/layer1/itjc/i4b_itjc_l1fsm.c optional itjc # isa/atkbd_isa.c optional atkbd isa/atkbdc_isa.c optional atkbdc isa/ppc.c optional ppc isa/psm.c optional psm isa/sio.c optional sio isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/md4c.c optional netsmb kern/subr_diskmbr.c standard libkern/divdi3.c standard libkern/moddi3.c standard libkern/qdivrem.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard netsmb/smb_conn.c optional netsmb netsmb/smb_crypt.c optional netsmb netsmb/smb_dev.c optional netsmb netsmb/smb_iod.c optional netsmb netsmb/smb_rq.c optional netsmb netsmb/smb_smb.c optional netsmb netsmb/smb_subr.c optional netsmb netsmb/smb_trantcp.c optional netsmb netsmb/smb_usr.c optional netsmb pci/ide_pci.c optional wdc pci Index: stable/4/sys/conf/files.pc98 =================================================================== --- stable/4/sys/conf/files.pc98 (revision 98399) +++ stable/4/sys/conf/files.pc98 (revision 98400) @@ -1,494 +1,493 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # # modified for PC-9801 # # $FreeBSD$ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # linux_genassym.o optional compat_linux \ dependency "$S/i386/linux/linux_genassym.c" \ compile-with "${CC} ${CFLAGS} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "linux_genassym.o" # svr4_genassym.o optional compat_svr4 \ dependency "$S/i386/svr4/svr4_genassym.c" \ compile-with "${CC} ${CFLAGS} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "svr4_genassym.o" # linux_assym.h optional compat_linux \ dependency "$S/kern/genassym.sh linux_genassym.o" \ compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # svr4_assym.h optional compat_svr4 \ dependency "$S/kern/genassym.sh svr4_genassym.o" \ compile-with "sh $S/kern/genassym.sh svr4_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "svr4_assym.h" # atkbdmap.h optional atkbd_dflt_keymap \ compile-with "/usr/sbin/kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "atkbdmap.h" # ukbdmap.h optional ukbd_dflt_keymap \ compile-with "/usr/sbin/kbdcontrol -L ${UKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > ukbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # compat/linux/linux_file.c optional compat_linux compat/linux/linux_getcwd.c optional compat_linux compat/linux/linux_ioctl.c optional compat_linux compat/linux/linux_ipc.c optional compat_linux compat/linux/linux_mib.c optional compat_linux compat/linux/linux_misc.c optional compat_linux compat/linux/linux_signal.c optional compat_linux compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux # contrib/dev/fla/fla.c optional fla msysosak.o optional fla \ dependency "$S/contrib/dev/fla/i386/msysosak.o.uu" \ compile-with "uudecode < $S/contrib/dev/fla/i386/msysosak.o.uu" \ no-implicit-rule # contrib/dev/oltr/if_oltr.c optional oltr trlld.o optional oltr \ dependency "$S/contrib/dev/oltr/i386${FMT}.trlld.o.uu" \ compile-with "uudecode < $S/contrib/dev/oltr/i386${FMT}.trlld.o.uu" \ no-implicit-rule contrib/dev/oltr/trlldbm.c optional oltr contrib/dev/oltr/trlldhm.c optional oltr contrib/dev/oltr/trlldmac.c optional oltr bf_enc.o optional ipsec ipsec_esp \ dependency "$S/crypto/blowfish/arch/i386/bf_enc.S $S/crypto/blowfish/arch/i386/bf_enc_586.S $S/crypto/blowfish/arch/i386/bf_enc_686.S" \ compile-with "${CC} -c -I$S/crypto/blowfish/arch/i386 ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}" \ no-implicit-rule crypto/des/arch/i386/des_enc.S optional ipsec ipsec_esp crypto/des/des_ecb.c optional netsmbcrypto crypto/des/arch/i386/des_enc.S optional netsmbcrypto crypto/des/des_setkey.c optional netsmbcrypto #dev/advansys/adv_isa.c optional adv isa dev/aic/aic_cbus.c optional aic isa dev/ar/if_ar_isa.c optional ar isa dev/ct/bshw_machdep.c optional ct dev/ct/ct.c optional ct dev/ct/ct_isa.c optional ct isa dev/dgb/dgm.c optional dgm dev/cm/if_cm_isa.c optional cm isa dev/ed/if_ed.c optional ed dev/ed/if_ed_cbus.c optional ed isa dev/ed/if_ed_pccard.c optional ed card dev/eisa/eisaconf.c optional eisa dev/em/if_em.c optional em -dev/em/if_em_fxhw.c optional em -dev/em/if_em_phy.c optional em +dev/em/if_em_hw.c optional em dev/fb/fb.c optional fb dev/fb/fb.c optional gdc dev/fb/splash.c optional splash dev/fe/if_fe_cbus.c optional fe isa dev/kbd/kbd.c optional kbd dev/kbd/kbd.c optional sc dev/kbd/kbd.c optional ukbd dev/kbd/kbd.c optional pckbd dev/puc/puc.c optional puc dev/puc/pucdata.c optional puc dev/sbni/if_sbni.c optional sbni dev/sbni/if_sbni_isa.c optional sbni isa dev/snc/dp83932.c optional snc dev/snc/dp83932subr.c optional snc dev/snc/if_snc.c optional snc dev/snc/if_snc_cbus.c optional snc isa dev/snc/if_snc_pccard.c optional snc card fs/smbfs/smbfs_io.c optional smbfs fs/smbfs/smbfs_node.c optional smbfs fs/smbfs/smbfs_smb.c optional smbfs fs/smbfs/smbfs_subr.c optional smbfs fs/smbfs/smbfs_vfsops.c optional smbfs fs/smbfs/smbfs_vnops.c optional smbfs gnu/i386/fpemul/div_small.s optional gpl_math_emulate gnu/i386/fpemul/errors.c optional gpl_math_emulate gnu/i386/fpemul/fpu_arith.c optional gpl_math_emulate gnu/i386/fpemul/fpu_aux.c optional gpl_math_emulate gnu/i386/fpemul/fpu_entry.c optional gpl_math_emulate gnu/i386/fpemul/fpu_etc.c optional gpl_math_emulate gnu/i386/fpemul/fpu_trig.c optional gpl_math_emulate gnu/i386/fpemul/get_address.c optional gpl_math_emulate gnu/i386/fpemul/load_store.c optional gpl_math_emulate gnu/i386/fpemul/poly_2xm1.c optional gpl_math_emulate gnu/i386/fpemul/poly_atan.c optional gpl_math_emulate gnu/i386/fpemul/poly_div.s optional gpl_math_emulate gnu/i386/fpemul/poly_l2.c optional gpl_math_emulate gnu/i386/fpemul/poly_mul64.s optional gpl_math_emulate gnu/i386/fpemul/poly_sin.c optional gpl_math_emulate gnu/i386/fpemul/poly_tan.c optional gpl_math_emulate gnu/i386/fpemul/polynomial.s optional gpl_math_emulate gnu/i386/fpemul/reg_add_sub.c optional gpl_math_emulate gnu/i386/fpemul/reg_compare.c optional gpl_math_emulate gnu/i386/fpemul/reg_constant.c optional gpl_math_emulate gnu/i386/fpemul/reg_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_ld_str.c optional gpl_math_emulate gnu/i386/fpemul/reg_mul.c optional gpl_math_emulate gnu/i386/fpemul/reg_norm.s optional gpl_math_emulate gnu/i386/fpemul/reg_round.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_add.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_div.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_mul.s optional gpl_math_emulate gnu/i386/fpemul/reg_u_sub.s optional gpl_math_emulate gnu/i386/fpemul/wm_shrx.s optional gpl_math_emulate gnu/i386/fpemul/wm_sqrt.s optional gpl_math_emulate gnu/i386/isa/dgb.c optional dgb gnu/i386/isa/sound/awe_wave.c optional awe pc98/apm/apm.c optional apm pc98/apm/apm_bioscall.s optional apm i386/i386/atomic.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}" i386/i386/autoconf.c standard i386/i386/bios.c standard i386/i386/bioscall.s standard i386/i386/busdma_machdep.c standard pc98/i386/busio.s standard pc98/i386/busiosubr.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb i386/i386/elf_machdep.c standard i386/i386/exception.s standard i386/i386/globals.s standard i386/i386/i386-gdbstub.c optional ddb i386/i386/i686_mem.c standard i386/i386/identcpu.c standard i386/i386/in_cksum.c optional inet i386/i386/initcpu.c standard i386/i386/k6_mem.c standard # locore.s needs to be handled in Makefile to put it first. Otherwise it's # now normal. # i386/i386/locore.s standard pc98/i386/machdep.c standard i386/i386/math_emulate.c optional math_emulate i386/i386/mem.c standard i386/i386/mp_clock.c optional smp i386/i386/mp_machdep.c optional smp i386/i386/mpapic.c optional smp i386/i386/mpboot.s optional smp i386/i386/mplock.s optional smp i386/i386/nexus.c standard i386/i386/perfmon.c optional perfmon i386/i386/perfmon.c optional perfmon profiling-routine i386/i386/pmap.c standard i386/i386/procfs_machdep.c standard i386/i386/simplelock.s optional smp i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard i386/i386/trap.c standard pc98/i386/userconfig.c optional userconfig i386/i386/vm86.c standard i386/i386/vm_machdep.c standard i386/ibcs2/ibcs2_errno.c optional ibcs2 i386/ibcs2/ibcs2_fcntl.c optional ibcs2 i386/ibcs2/ibcs2_ioctl.c optional ibcs2 i386/ibcs2/ibcs2_ipc.c optional ibcs2 i386/ibcs2/ibcs2_isc.c optional ibcs2 i386/ibcs2/ibcs2_isc_sysent.c optional ibcs2 i386/ibcs2/ibcs2_misc.c optional ibcs2 i386/ibcs2/ibcs2_msg.c optional ibcs2 i386/ibcs2/ibcs2_other.c optional ibcs2 i386/ibcs2/ibcs2_signal.c optional ibcs2 i386/ibcs2/ibcs2_socksys.c optional ibcs2 i386/ibcs2/ibcs2_stat.c optional ibcs2 i386/ibcs2/ibcs2_sysent.c optional ibcs2 i386/ibcs2/ibcs2_sysi86.c optional ibcs2 i386/ibcs2/ibcs2_sysvec.c optional ibcs2 i386/ibcs2/ibcs2_util.c optional ibcs2 i386/ibcs2/ibcs2_xenix.c optional ibcs2 i386/ibcs2/ibcs2_xenix_sysent.c optional ibcs2 i386/ibcs2/imgact_coff.c optional ibcs2 pc98/pc98/pc98_machdep.c standard i386/isa/bs/bs.c optional bs i386/isa/bs/bsfunc.c optional bs i386/isa/bs/bshw.c optional bs i386/isa/bs/bsif.c optional bs i386/isa/asc.c optional asc pc98/pc98/atapi.c optional wdc pc98/pc98/clock.c standard i386/isa/cronyx.c optional cx i386/isa/ctx.c optional ctx i386/isa/cx.c optional cx i386/isa/cy.c optional cy pc98/pc98/diskslice_machdep.c standard i386/isa/elink.c optional ep i386/isa/elink.c optional ie pc98/pc98/fd.c optional fd i386/isa/gpib.c optional gp i386/isa/gsc.c optional gsc i386/isa/if_ar.c optional ar i386/isa/if_cx.c optional cx i386/isa/if_el.c optional el i386/isa/if_le.c optional le i386/isa/if_lnc.c optional lnc i386/isa/if_rdp.c optional rdp i386/isa/if_sr.c optional sr i386/isa/if_wl.c optional wl i386/isa/intr_machdep.c standard i386/isa/ipl_funcs.c standard \ compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}" i386/isa/isa.c optional isa pc98/pc98/isa_compat.c optional isa pc98/pc98/isa_dma.c optional isa i386/isa/istallion.c optional stli i386/isa/labpc.c optional labpc i386/isa/loran.c optional loran i386/isa/matcd/matcd.c optional matcd i386/isa/mca_machdep.c optional mca i386/isa/mcd.c optional mcd pc98/pc98/mse.c optional mse pc98/pc98/npx.c mandatory npx pc98/pc98/olpt.c optional olpt pc98/pc98/pc98gdc.c optional gdc pc98/pc98/pc98kbd.c optional pckbd pc98/pc98/pcaudio.c optional pca i386/isa/pcf.c optional pcf i386/isa/pci_cfgreg.c optional pci i386/isa/pcibus.c optional pci i386/isa/pcvt/pcvt_drv.c optional vt i386/isa/pcvt/pcvt_ext.c optional vt i386/isa/pcvt/pcvt_kbd.c optional vt i386/isa/pcvt/pcvt_out.c optional vt i386/isa/pcvt/pcvt_sup.c optional vt i386/isa/pcvt/pcvt_vtf.c optional vt pc98/pc98/pmc.c optional pmc pc98/pc98/ppc.c optional ppc i386/isa/prof_machdep.c optional profiling-routine i386/isa/rc.c optional rc i386/isa/rp.c optional rp i386/isa/scd.c optional scd pc98/pc98/sio.c optional sio i386/isa/sound/ad1848.c optional css i386/isa/sound/ad1848.c optional gus i386/isa/sound/ad1848.c optional gusxvi i386/isa/sound/ad1848.c optional mss i386/isa/sound/ad1848.c optional sscape i386/isa/sound/ad1848.c optional trix i386/isa/sound/ad1848.c optional sscape_mss i386/isa/sound/adlib_card.c optional opl i386/isa/sound/adlib_card.c optional trix i386/isa/sound/audio.c optional snd i386/isa/sound/cs4232.c optional css i386/isa/sound/dev_table.c optional snd i386/isa/sound/dmabuf.c optional snd i386/isa/sound/gus_card.c optional gus i386/isa/sound/gus_midi.c optional gus i386/isa/sound/gus_vol.c optional gus i386/isa/sound/gus_wave.c optional gus i386/isa/sound/ics2101.c optional gus i386/isa/sound/midi_synth.c optional css i386/isa/sound/midi_synth.c optional gus i386/isa/sound/midi_synth.c optional mpu i386/isa/sound/midi_synth.c optional mss i386/isa/sound/midi_synth.c optional pas i386/isa/sound/midi_synth.c optional sb i386/isa/sound/midi_synth.c optional sscape i386/isa/sound/midi_synth.c optional uart i386/isa/sound/midibuf.c optional css i386/isa/sound/midibuf.c optional gus i386/isa/sound/midibuf.c optional mpu i386/isa/sound/midibuf.c optional mss i386/isa/sound/midibuf.c optional nss i386/isa/sound/midibuf.c optional pas i386/isa/sound/midibuf.c optional sb i386/isa/sound/midibuf.c optional sscape i386/isa/sound/midibuf.c optional uart i386/isa/sound/mpu401.c optional mpu i386/isa/sound/mpu401.c optional sscape i386/isa/sound/opl3.c optional opl i386/isa/sound/opl3.c optional trix i386/isa/sound/pas2_card.c optional pas i386/isa/sound/pas2_midi.c optional pas i386/isa/sound/pas2_mixer.c optional pas i386/isa/sound/pas2_pcm.c optional pas i386/isa/sound/patmgr.c optional snd i386/isa/sound/pcm86.c optional nss i386/isa/sound/sb16_dsp.c optional sbxvi i386/isa/sound/sb16_midi.c optional sbmidi i386/isa/sound/sb_card.c optional sb i386/isa/sound/sb_dsp.c optional sb i386/isa/sound/sb_midi.c optional sb i386/isa/sound/sb_mixer.c optional sb i386/isa/sound/sequencer.c optional snd i386/isa/sound/sound_switch.c optional snd i386/isa/sound/sound_timer.c optional css i386/isa/sound/sound_timer.c optional gus i386/isa/sound/sound_timer.c optional mss i386/isa/sound/sound_timer.c optional mss i386/isa/sound/sound_timer.c optional sscape i386/isa/sound/sound_timer.c optional trix i386/isa/sound/soundcard.c optional snd i386/isa/sound/sscape.c optional sscape i386/isa/sound/sys_timer.c optional snd i386/isa/sound/trix.c optional trix i386/isa/sound/uart6850.c optional uart i386/isa/spigot.c optional spigot pc98/pc98/spkr.c optional speaker i386/isa/stallion.c optional stl pc98/pc98/syscons.c optional sc pc98/pc98/syscons_pc98.c optional sc dev/syscons/schistory.c optional sc dev/syscons/scmouse.c optional sc pc98/pc98/scgdcrndr.c optional sc gdc dev/syscons/scterm.c optional sc dev/syscons/scterm-dumb.c optional sc pc98/pc98/scterm-sck.c optional sc dev/syscons/scvidctl.c optional sc pc98/pc98/scvtbpc98.c optional sc dev/syscons/sysmouse.c optional sc i386/isa/tw.c optional tw pc98/pc98/wd.c optional wdc pc98/pc98/wd.c optional wd i386/isa/wd_cd.c optional wcd wdc i386/isa/wfd.c optional wfd wdc i386/isa/wst.c optional wst wdc i386/isa/wt.c optional wt i386/linux/imgact_linux.c optional compat_linux i386/linux/linux_dummy.c optional compat_linux i386/linux/linux_locore.s optional compat_linux \ dependency "linux_assym.h" i386/linux/linux_machdep.c optional compat_linux i386/linux/linux_sysent.c optional compat_linux i386/linux/linux_sysvec.c optional compat_linux svr4/imgact_svr4.c optional compat_svr4 svr4/svr4_fcntl.c optional compat_svr4 svr4/svr4_filio.c optional compat_svr4 svr4/svr4_ioctl.c optional compat_svr4 svr4/svr4_ipc.c optional compat_svr4 svr4/svr4_misc.c optional compat_svr4 svr4/svr4_resource.c optional compat_svr4 svr4/svr4_signal.c optional compat_svr4 svr4/svr4_socket.c optional compat_svr4 svr4/svr4_sockio.c optional compat_svr4 svr4/svr4_stat.c optional compat_svr4 svr4/svr4_stream.c optional compat_svr4 svr4/svr4_syscallnames.c optional compat_svr4 svr4/svr4_sysent.c optional compat_svr4 svr4/svr4_sysvec.c optional compat_svr4 svr4/svr4_termios.c optional compat_svr4 svr4/svr4_ttold.c optional compat_svr4 i386/svr4/svr4_locore.s optional compat_svr4 \ dependency "svr4_assym.h" i386/svr4/svr4_machdep.c optional compat_svr4 # # isdn4bsd, needed for isic | iwic | ifpi | | ifpi2 | ihfc | ifpnp | itjc # i4b/layer1/i4b_l1dmux.c optional isic i4b/layer1/i4b_l1lib.c optional isic i4b/layer1/i4b_l1dmux.c optional iwic i4b/layer1/i4b_l1lib.c optional iwic i4b/layer1/i4b_l1dmux.c optional ifpi i4b/layer1/i4b_l1lib.c optional ifpi i4b/layer1/i4b_l1dmux.c optional ifpi2 i4b/layer1/i4b_l1lib.c optional ifpi2 i4b/layer1/i4b_l1dmux.c optional ihfc i4b/layer1/i4b_l1lib.c optional ihfc i4b/layer1/i4b_l1dmux.c optional ifpnp i4b/layer1/i4b_l1lib.c optional ifpnp i4b/layer1/i4b_l1dmux.c optional itjc i4b/layer1/i4b_l1lib.c optional itjc # # isdn4bsd, isic # i4b/layer1/isic/i4b_asuscom_ipac.c optional isic i4b/layer1/isic/i4b_avm_a1.c optional isic i4b/layer1/isic/i4b_bchan.c optional isic i4b/layer1/isic/i4b_ctx_s0P.c optional isic i4b/layer1/isic/i4b_drn_ngo.c optional isic i4b/layer1/isic/i4b_dynalink.c optional isic i4b/layer1/isic/i4b_elsa_qs1i.c optional isic i4b/layer1/isic/i4b_elsa_qs1p.c optional isic i4b/layer1/isic/i4b_elsa_pcc16.c optional isic i4b/layer1/isic/i4b_hscx.c optional isic i4b/layer1/isic/i4b_isac.c optional isic i4b/layer1/isic/i4b_isic.c optional isic i4b/layer1/isic/i4b_isic_isa.c optional isic i4b/layer1/isic/i4b_isic_pnp.c optional isic i4b/layer1/isic/i4b_itk_ix1.c optional isic i4b/layer1/isic/i4b_l1.c optional isic i4b/layer1/isic/i4b_l1fsm.c optional isic i4b/layer1/isic/i4b_siemens_isurf.c optional isic i4b/layer1/isic/i4b_sws.c optional isic i4b/layer1/isic/i4b_tel_s016.c optional isic i4b/layer1/isic/i4b_tel_s0163.c optional isic i4b/layer1/isic/i4b_tel_s08.c optional isic i4b/layer1/isic/i4b_usr_sti.c optional isic i4b/layer1/isic/i4b_diva.c optional isic # # isdn4bsd, iwic # i4b/layer1/iwic/i4b_iwic_pci.c optional iwic i4b/layer1/iwic/i4b_iwic_dchan.c optional iwic i4b/layer1/iwic/i4b_iwic_bchan.c optional iwic i4b/layer1/iwic/i4b_iwic_fsm.c optional iwic i4b/layer1/iwic/i4b_iwic_l1if.c optional iwic # # isdn4bsd, ifpi # i4b/layer1/ifpi/i4b_ifpi_pci.c optional ifpi i4b/layer1/ifpi/i4b_ifpi_isac.c optional ifpi i4b/layer1/ifpi/i4b_ifpi_l1.c optional ifpi i4b/layer1/ifpi/i4b_ifpi_l1fsm.c optional ifpi # # isdn4bsd, ifpi2 # i4b/layer1/ifpi2/i4b_ifpi2_pci.c optional ifpi2 i4b/layer1/ifpi2/i4b_ifpi2_isacsx.c optional ifpi2 i4b/layer1/ifpi2/i4b_ifpi2_l1.c optional ifpi2 i4b/layer1/ifpi2/i4b_ifpi2_l1fsm.c optional ifpi2 # # isdn4bsd, ifpnp # i4b/layer1/ifpnp/i4b_ifpnp_avm.c optional ifpnp i4b/layer1/ifpnp/i4b_ifpnp_isac.c optional ifpnp i4b/layer1/ifpnp/i4b_ifpnp_l1.c optional ifpnp i4b/layer1/ifpnp/i4b_ifpnp_l1fsm.c optional ifpnp # # isdn4bsd, ihfc # i4b/layer1/ihfc/i4b_ihfc_l1if.c optional ihfc i4b/layer1/ihfc/i4b_ihfc_pnp.c optional ihfc i4b/layer1/ihfc/i4b_ihfc_drv.c optional ihfc # # isdn4bsd, itjc # i4b/layer1/itjc/i4b_itjc_pci.c optional itjc i4b/layer1/itjc/i4b_itjc_isac.c optional itjc i4b/layer1/itjc/i4b_itjc_l1.c optional itjc i4b/layer1/itjc/i4b_itjc_l1fsm.c optional itjc # isa/psm.c optional psm kern/md4c.c optional netsmb kern/subr_diskmbr.c optional compat_atdisk libkern/divdi3.c standard libkern/moddi3.c standard libkern/qdivrem.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard netsmb/smb_conn.c optional netsmb netsmb/smb_crypt.c optional netsmb netsmb/smb_dev.c optional netsmb netsmb/smb_iod.c optional netsmb netsmb/smb_rq.c optional netsmb netsmb/smb_smb.c optional netsmb netsmb/smb_subr.c optional netsmb netsmb/smb_trantcp.c optional netsmb netsmb/smb_usr.c optional netsmb pccard/mecia.c optional mecia isa card #pci/ide_pci.c optional wd Index: stable/4/sys/dev/em/README =================================================================== --- stable/4/sys/dev/em/README (revision 98399) +++ stable/4/sys/dev/em/README (revision 98400) @@ -1,281 +1,281 @@ $FreeBSD$ FreeBSD* Driver for the Intel(R) PRO/1000 Family of Adapters ============================================================ April 3, 2002 Contents ======== - In This Release - Supported Adapters - Building and Installation - Speed and Duplex Configuration - Additional Configurations - Known Limitations - Support - License In This Release =============== This file describes the FreeBSD* driver, version 1.3.x, for the Intel(R) PRO/1000 Family of Adapters. This driver has been developed for use with FreeBSD, version 4.5. The driver supports Transmit/Receive Checksum Offload and Jumbo Frames on all but the 82542-based adapters. For specific adapters, refer to the Supported Adapters section below. Support for VLANs has been added as a new feature in this driver version. For questions related to hardware requirements, refer to the documentation supplied with your Intel PRO/1000 adapter. All hardware requirements listed apply to use with FreeBSD. Supported Adapters ================== The following Intel network adapters are compatible with the drivers in this release: Controller Adapter Name Board IDs ---------- ------------ --------- 82542 PRO/1000 Gigabit Server Adapter 700262-xxx, 717037-xxx 82543 PRO/1000 F Server Adapter 738640-xxx, A38888-xxx, A06512-xxx 82543 PRO/1000 T Server Adapter A19845-xxx, A33948-xxx 82544 PRO/1000 XT Server Adapter A51580-xxx 82544 PRO/1000 XF Server Adapter A50484-xxx 82544 PRO/1000 T Desktop Adapter A62947-xxx 82540 PRO/1000 MT Desktop Adapter A78708-xxx 82545 PRO/1000 MT Server Adapter A92165-xxx 82545 PRO/1000 MF Server Adapter A91622-xxx 82545 PRO/1000 MF Server Adapter(LX) A91624-xxx 82546 PRO/1000 MT Dual Port Server Adapter A92111-xxx 82546 PRO/1000 MF Dual Port Server Adapter A91620-xxx To verify your Intel adapter is supported, find the board ID number on the adapter. Look for a label that has a barcode and a number in the format of 123456-001 (six digits hyphen three digits). Match this to the list of numbers above. For more information on how to identify your adapter, go to the Adapter & Driver ID Guide at: http://support.intel.com/support/network/adapter/pro100/21397.htm For the latest Intel network drivers for FreeBSD, see: http://appsr.intel.com/scripts-df/support_intel.asp Building and Installation ========================= NOTE: You must have kernel sources installed in order to compile the driver module. In the instructions below, x.x.x is the driver version as indicated in the name of the driver tar. 1. Move the base driver tar file to the directory of your choice. For example, use /home/username/em or /usr/local/src/em. 2. Untar/unzip the archive: tar xfz em-x.x.x.tar.gz 3. To load the driver onto a running system: cd em-x.x.x/modules kldload ./if_em.ko 4. To assign an IP address to the interface, enter the following: ifconfig em 5. Verify that the interface works. Enter the following, where is the IP address for another machine on the same subnet as the interface that is being tested: ping 6. If you want the driver to load automatically when the system is booted: cd em-x.x.x/modules cp if_em.ko /modules Edit /boot/loader.conf, and add the following line: if_em_load="YES" OR compile the driver into the kernel (see item 7). Edit /etc/rc.conf, and create the appropriate ifconfig_em entry: ifconfig_em="" Example usage: ifconfig_em0="inet 192.168.10.1 netmask 255.255.255.0" NOTE: For assistance, see the ifconfig man page. 7. If you want to compile the driver into the kernel, enter: mkdir /usr/src/sys/dev/em cd em-x.x.x/src cp if_em* /usr/src/sys/dev/em mkdir /usr/src/sys/modules/em cp Makefile /usr/src/sys/modules/em Edit Makefile at /usr/src/sys/modules to add the em subdirectory. Edit your config file and add the following line, if it is not already in the file: device em Edit your config file, and remove the 'device wx' line from the file. Edit the /usr/src/sys/conf/files.i386 file, and add the following lines: dev/em/if_em.c optional em dev/em/if_em_hw.c optional em Remove the following files from the /usr/src/sys/conf/files.i386 file, if they exist: - /dev/em/if_em_fxhw.c + /dev/em/if_em_fx_hw.c /dev/em/if_em_phy.c Compile and install the kernel. Speed and Duplex Configuration ============================== By default, the adapter auto-negotiates the speed and duplex of the connection. If there is a specific need, the ifconfig utility can be used to configure the speed and duplex settings on the adapter. Example usage: ifconfig em media 100baseTX mediaopt full-duplex NOTE: Only use mediaopt to set the driver to full-duplex. If mediaopt is not specified and you are not running at gigabit speed, the driver defaults to half-duplex. This driver supports the following media type options: autoselect - Enables auto-negotiation for speed and duplex. 10baseT/UTP - Sets speed to 10 Mbps. Use the ifconfig mediaopt option to select full-duplex mode. 100baseTX - Sets speed to 100 Mbps. Use the ifconfig mediaopt option to select full-duplex mode. 1000baseTX - Sets speed to 1000 Mbps. In this case, the driver supports only full-duplex mode. 1000baseSX - Sets speed to 1000 Mbps. In this case, the driver supports only full-duplex mode. For more information on the ifconfig utility, see the ifconfig man page. Additional Configurations ========================= Jumbo Frames ------------ To enable Jumbo Frames, use the ifconfig utility to increase the MTU beyond 1500 bytes. NOTE: Only enable Jumbo Frames if your network infrastructure supports them. The MTU range for Jumbo Frames is 1500 to 16114. For example, enter the following: ifconfig em mtu 9000 VLANs ----- To enable VLANs in the kernel, modify the config file as follows: pseudo-device vlan Then, recompile the kernel and reboot. To see the VLAN device entries, use ifconfig. To attach a VLAN to the driver enter the following: ifconfig vlan0 inet 10.0.0.1 netmask 255.255.255.0 vlan 1 vlandev em0 mtu 1500 up Also, bring the driver up by entering: ifconfig em0 up Known Limitations ================= There are known performance problems with this driver when running UDP traffic with Jumbo Frames. Intel recommends not using Jumbo Frames for UDP traffic. Support ======= For general information and support, go to the Intel support website at: http://support.intel.com If an issue is identified with the released source code on the supported kernel with a supported adapter, email the specific information related to the issue to freebsdnic@mailbox.intel.com. License ======= This software program is released under the terms of a license agreement between you ('Licensee') and Intel. Do not use or load this software or any associated materials (collectively, the 'Software') until you have carefully read the full terms and conditions of the LICENSE located in this software package. By loading or using the Software, you agree to the terms of this Agreement. If you do not agree with the terms of this Agreement, do not install or use the Software. * Other names and brands may be claimed as the property of others. Index: stable/4/sys/dev/em/if_em.c =================================================================== --- stable/4/sys/dev/em/if_em.c (revision 98399) +++ stable/4/sys/dev/em/if_em.c (revision 98400) @@ -1,2242 +1,2368 @@ /************************************************************************** Copyright (c) 2001-2002 Intel Corporation All rights reserved. Redistribution and use in source and binary forms of the Software, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code of the Software may retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form of the Software may reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the Intel Corporation nor the names of its contributors shall be used to endorse or promote products derived from this Software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ /*$FreeBSD$*/ #include /********************************************************************* * Set this to one to display debug statistics *********************************************************************/ int em_display_debug_stats = 0; /********************************************************************* * Linked list of board private structures for all NICs found *********************************************************************/ struct adapter *em_adapter_list = NULL; /********************************************************************* * Driver version *********************************************************************/ -char em_driver_version[] = "1.2.7"; +char em_driver_version[] = "1.3.8"; /********************************************************************* * PCI Device ID Table * * Used by probe to select devices to load on * Last field stores an index into em_strings * Last entry must be all 0s * * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, String Index } *********************************************************************/ static em_vendor_info_t em_vendor_info_array[] = { - /* Intel(R) PRO/1000 Network Connection */ - { 0x8086, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x1004, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x1008, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x1009, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x100C, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x100D, PCI_ANY_ID, PCI_ANY_ID, 0 }, - { 0x8086, 0x100E, PCI_ANY_ID, PCI_ANY_ID, 0 }, - /* required last entry */ - { 0, 0, 0, 0, 0} + /* Intel(R) PRO/1000 Network Connection */ + { 0x8086, 0x1000, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1001, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1004, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1008, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1009, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x100C, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x100D, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x100E, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x100F, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1010, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1011, PCI_ANY_ID, PCI_ANY_ID, 0}, + { 0x8086, 0x1012, PCI_ANY_ID, PCI_ANY_ID, 0}, + /* required last entry */ + { 0, 0, 0, 0, 0} }; /********************************************************************* * Table of branding strings for all supported NICs. *********************************************************************/ static char *em_strings[] = { - "Intel(R) PRO/1000 Network Connection" + "Intel(R) PRO/1000 Network Connection" }; /********************************************************************* * Function prototypes *********************************************************************/ static int em_probe __P((device_t)); static int em_attach __P((device_t)); static int em_detach __P((device_t)); static int em_shutdown __P((device_t)); static void em_intr __P((void *)); static void em_start __P((struct ifnet *)); static int em_ioctl __P((struct ifnet *, IOCTL_CMD_TYPE, caddr_t)); static void em_watchdog __P((struct ifnet *)); static void em_init __P((void *)); static void em_stop __P((void *)); static void em_media_status __P((struct ifnet *, struct ifmediareq *)); static int em_media_change __P((struct ifnet *)); static void em_identify_hardware __P((struct adapter *)); static int em_allocate_pci_resources __P((struct adapter *)); static void em_free_pci_resources __P((struct adapter *)); static void em_local_timer __P((void *)); static int em_hardware_init __P((struct adapter *)); -static void em_read_mac_address __P((struct adapter *, u_int8_t *)); static void em_setup_interface __P((device_t, struct adapter *)); static int em_setup_transmit_structures __P((struct adapter *)); static void em_initialize_transmit_unit __P((struct adapter *)); static int em_setup_receive_structures __P((struct adapter *)); static void em_initialize_receive_unit __P((struct adapter *)); static void em_enable_intr __P((struct adapter *)); static void em_disable_intr __P((struct adapter *)); static void em_free_transmit_structures __P((struct adapter *)); static void em_free_receive_structures __P((struct adapter *)); static void em_update_stats_counters __P((struct adapter *)); static void em_clean_transmit_interrupts __P((struct adapter *)); static int em_allocate_receive_structures __P((struct adapter *)); static int em_allocate_transmit_structures __P((struct adapter *)); static void em_process_receive_interrupts __P((struct adapter *)); static void em_receive_checksum __P((struct adapter *, - struct em_rx_desc * rx_desc, - struct mbuf *)); + struct em_rx_desc * rx_desc, + struct mbuf *)); static void em_transmit_checksum_setup __P((struct adapter *, - struct mbuf *, - struct em_tx_buffer *, - u_int32_t *, - u_int32_t *)); + struct mbuf *, + struct em_tx_buffer *, + u_int32_t *, + u_int32_t *)); static void em_set_promisc __P((struct adapter *)); static void em_disable_promisc __P((struct adapter *)); static void em_set_multi __P((struct adapter *)); static void em_print_hw_stats __P((struct adapter *)); static void em_print_link_status __P((struct adapter *)); static int em_get_buf __P((struct em_rx_buffer *, struct adapter *, - struct mbuf *)); + struct mbuf *)); +static void em_enable_vlans __P((struct adapter *adapter)); + /********************************************************************* * FreeBSD Device Interface Entry Points *********************************************************************/ static device_method_t em_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, em_probe), - DEVMETHOD(device_attach, em_attach), - DEVMETHOD(device_detach, em_detach), - DEVMETHOD(device_shutdown, em_shutdown), - {0, 0} + /* Device interface */ + DEVMETHOD(device_probe, em_probe), + DEVMETHOD(device_attach, em_attach), + DEVMETHOD(device_detach, em_detach), + DEVMETHOD(device_shutdown, em_shutdown), + {0, 0} }; static driver_t em_driver = { - "em", em_methods, sizeof(struct adapter ), + "em", em_methods, sizeof(struct adapter ), }; static devclass_t em_devclass; DRIVER_MODULE(if_em, pci, em_driver, em_devclass, 0, 0); /********************************************************************* * Device identification routine * * em_probe determines if the driver should be loaded on * adapter based on PCI vendor/device id of the adapter. * * return 0 on success, positive on failure *********************************************************************/ static int em_probe(device_t dev) { - em_vendor_info_t *ent; + em_vendor_info_t *ent; - u_int16_t pci_vendor_id = 0; - u_int16_t pci_device_id = 0; - u_int16_t pci_subvendor_id = 0; - u_int16_t pci_subdevice_id = 0; - char adapter_name[60]; + u_int16_t pci_vendor_id = 0; + u_int16_t pci_device_id = 0; + u_int16_t pci_subvendor_id = 0; + u_int16_t pci_subdevice_id = 0; + char adapter_name[60]; - INIT_DEBUGOUT("em_probe: begin"); + INIT_DEBUGOUT("em_probe: begin"); - pci_vendor_id = pci_get_vendor(dev); - if (pci_vendor_id != EM_VENDOR_ID) - return (ENXIO); + pci_vendor_id = pci_get_vendor(dev); + if (pci_vendor_id != EM_VENDOR_ID) + return(ENXIO); - pci_device_id = pci_get_device(dev); - pci_subvendor_id = pci_get_subvendor(dev); - pci_subdevice_id = pci_get_subdevice(dev); + pci_device_id = pci_get_device(dev); + pci_subvendor_id = pci_get_subvendor(dev); + pci_subdevice_id = pci_get_subdevice(dev); - ent = em_vendor_info_array; - while(ent->vendor_id != 0) { - if ((pci_vendor_id == ent->vendor_id) && - (pci_device_id == ent->device_id) && - - ((pci_subvendor_id == ent->subvendor_id) || - (ent->subvendor_id == PCI_ANY_ID)) && + ent = em_vendor_info_array; + while (ent->vendor_id != 0) { + if ((pci_vendor_id == ent->vendor_id) && + (pci_device_id == ent->device_id) && - ((pci_subdevice_id == ent->subdevice_id) || - (ent->subdevice_id == PCI_ANY_ID))) { - INIT_DEBUGOUT1("em_probe: Found PRO/1000 (pci_device_id=0x%x)", - pci_device_id); - sprintf(adapter_name, "%s, Version - %s", em_strings[ent->index], - em_driver_version); - device_set_desc_copy(dev, adapter_name); - return(0); - } - ent++; - } + ((pci_subvendor_id == ent->subvendor_id) || + (ent->subvendor_id == PCI_ANY_ID)) && - return (ENXIO); + ((pci_subdevice_id == ent->subdevice_id) || + (ent->subdevice_id == PCI_ANY_ID))) { + sprintf(adapter_name, "%s, Version - %s", + em_strings[ent->index], + em_driver_version); + device_set_desc_copy(dev, adapter_name); + return(0); + } + ent++; + } + + return(ENXIO); } /********************************************************************* * Device initialization routine * * The attach entry point is called when the driver is being loaded. * This routine identifies the type of hardware, allocates all resources * and initializes the hardware. * * return 0 on success, positive on failure *********************************************************************/ static int em_attach(device_t dev) { - struct adapter * adapter; - int s; - int tsize, rsize; + struct adapter * adapter; + int s; + int tsize, rsize; - INIT_DEBUGOUT("em_attach: begin"); - s = splimp(); + INIT_DEBUGOUT("em_attach: begin"); + s = splimp(); - /* Allocate, clear, and link in our adapter structure */ - if (!(adapter = device_get_softc(dev))) { - printf("em: adapter structure allocation failed\n"); - splx(s); - return(ENOMEM); - } - bzero(adapter, sizeof(struct adapter )); - adapter->dev = dev; - adapter->osdep.dev = dev; - adapter->unit = device_get_unit(dev); + /* Allocate, clear, and link in our adapter structure */ + if (!(adapter = device_get_softc(dev))) { + printf("em: adapter structure allocation failed\n"); + splx(s); + return(ENOMEM); + } + bzero(adapter, sizeof(struct adapter )); + adapter->dev = dev; + adapter->osdep.dev = dev; + adapter->unit = device_get_unit(dev); - if (em_adapter_list != NULL) - em_adapter_list->prev = adapter; - adapter->next = em_adapter_list; - em_adapter_list = adapter; + if (em_adapter_list != NULL) + em_adapter_list->prev = adapter; + adapter->next = em_adapter_list; + em_adapter_list = adapter; - callout_handle_init(&adapter->timer_handle); + callout_handle_init(&adapter->timer_handle); - /* Determine hardware revision */ - em_identify_hardware(adapter); + /* Determine hardware revision */ + em_identify_hardware(adapter); - /* Parameters (to be read from user) */ - adapter->num_tx_desc = MAX_TXD; - adapter->num_rx_desc = MAX_RXD; - adapter->tx_int_delay = TIDV; - adapter->rx_int_delay = RIDV; - adapter->shared.autoneg = DO_AUTO_NEG; - adapter->shared.wait_autoneg_complete = WAIT_FOR_AUTO_NEG_DEFAULT; - adapter->shared.autoneg_advertised = AUTONEG_ADV_DEFAULT; - adapter->shared.tbi_compatibility_en = TRUE; - adapter->rx_buffer_len = EM_RXBUFFER_2048; - adapter->rx_checksum = EM_ENABLE_RXCSUM_OFFLOAD; - - adapter->shared.fc_high_water = FC_DEFAULT_HI_THRESH; - adapter->shared.fc_low_water = FC_DEFAULT_LO_THRESH; - adapter->shared.fc_pause_time = FC_DEFAULT_TX_TIMER; - adapter->shared.fc_send_xon = TRUE; - adapter->shared.fc = em_fc_full; + /* Parameters (to be read from user) */ + adapter->num_tx_desc = MAX_TXD; + adapter->num_rx_desc = MAX_RXD; + adapter->tx_int_delay = TIDV; + adapter->rx_int_delay = RIDV; + adapter->hw.autoneg = DO_AUTO_NEG; + adapter->hw.wait_autoneg_complete = WAIT_FOR_AUTO_NEG_DEFAULT; + adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; + adapter->hw.tbi_compatibility_en = TRUE; + adapter->rx_buffer_len = EM_RXBUFFER_2048; + adapter->rx_checksum = EM_ENABLE_RXCSUM_OFFLOAD; - /* Set the max frame size assuming standard ethernet sized frames */ - adapter->shared.max_frame_size = ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; - adapter->shared.min_frame_size = MINIMUM_ETHERNET_PACKET_SIZE + ETHER_CRC_LEN; + adapter->hw.fc_high_water = FC_DEFAULT_HI_THRESH; + adapter->hw.fc_low_water = FC_DEFAULT_LO_THRESH; + adapter->hw.fc_pause_time = FC_DEFAULT_TX_TIMER; + adapter->hw.fc_send_xon = TRUE; + adapter->hw.fc = em_fc_full; - /* This controls when hardware reports transmit completion status. */ - if ((EM_REPORT_TX_EARLY == 0) || (EM_REPORT_TX_EARLY == 1)) { - adapter->shared.report_tx_early = EM_REPORT_TX_EARLY; - } else { - if(adapter->shared.mac_type < em_82543) { - adapter->shared.report_tx_early = 0; - } else { - adapter->shared.report_tx_early = 1; - } - } + /* Set the max frame size assuming standard ethernet sized frames */ + adapter->hw.max_frame_size = + ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN; - if (em_allocate_pci_resources(adapter)) { - printf("em%d: Allocation of PCI resources failed\n", adapter->unit); - em_free_pci_resources(adapter); - splx(s); - return(ENXIO); - } + adapter->hw.min_frame_size = + MINIMUM_ETHERNET_PACKET_SIZE + ETHER_CRC_LEN; - tsize = EM_ROUNDUP(adapter->num_tx_desc * - sizeof(struct em_tx_desc), 4096); + /* This controls when hardware reports transmit completion status. */ + if ((EM_REPORT_TX_EARLY == 0) || (EM_REPORT_TX_EARLY == 1)) { + adapter->hw.report_tx_early = EM_REPORT_TX_EARLY; + } else { + if (adapter->hw.mac_type < em_82543) { + adapter->hw.report_tx_early = 0; + } else { + adapter->hw.report_tx_early = 1; + } + } - /* Allocate Transmit Descriptor ring */ - if (!(adapter->tx_desc_base = (struct em_tx_desc *) - contigmalloc(tsize, M_DEVBUF, M_NOWAIT, 0, ~0, PAGE_SIZE, 0))) { - printf("em%d: Unable to allocate TxDescriptor memory\n", adapter->unit); - em_free_pci_resources(adapter); - splx(s); - return(ENOMEM); - } + if (em_allocate_pci_resources(adapter)) { + printf("em%d: Allocation of PCI resources failed\n", + adapter->unit); + em_free_pci_resources(adapter); + splx(s); + return(ENXIO); + } - rsize = EM_ROUNDUP(adapter->num_rx_desc * - sizeof(struct em_rx_desc), 4096); + tsize = EM_ROUNDUP(adapter->num_tx_desc * + sizeof(struct em_tx_desc), 4096); - /* Allocate Receive Descriptor ring */ - if (!(adapter->rx_desc_base = (struct em_rx_desc *) - contigmalloc(rsize, M_DEVBUF, M_NOWAIT, 0, ~0, PAGE_SIZE, 0))) { - printf("em%d: Unable to allocate rx_desc memory\n", adapter->unit); - em_free_pci_resources(adapter); - contigfree(adapter->tx_desc_base, tsize, M_DEVBUF); - splx(s); - return(ENOMEM); - } + /* Allocate Transmit Descriptor ring */ + if (!(adapter->tx_desc_base = (struct em_tx_desc *) + contigmalloc(tsize, M_DEVBUF, M_NOWAIT, 0, ~0, PAGE_SIZE, 0))) { + printf("em%d: Unable to allocate TxDescriptor memory\n", + adapter->unit); + em_free_pci_resources(adapter); + splx(s); + return(ENOMEM); + } - /* Initialize the hardware */ - if (em_hardware_init(adapter)) { - printf("em%d: Unable to initialize the hardware\n",adapter->unit); - em_free_pci_resources(adapter); - contigfree(adapter->tx_desc_base, tsize, M_DEVBUF); - contigfree(adapter->rx_desc_base, rsize, M_DEVBUF); - splx(s); - return(EIO); - } + rsize = EM_ROUNDUP(adapter->num_rx_desc * + sizeof(struct em_rx_desc), 4096); - /* Setup OS specific network interface */ - em_setup_interface(dev, adapter); + /* Allocate Receive Descriptor ring */ + if (!(adapter->rx_desc_base = (struct em_rx_desc *) + contigmalloc(rsize, M_DEVBUF, M_NOWAIT, 0, ~0, PAGE_SIZE, 0))) { + printf("em%d: Unable to allocate rx_desc memory\n", + adapter->unit); + em_free_pci_resources(adapter); + contigfree(adapter->tx_desc_base, tsize, M_DEVBUF); + splx(s); + return(ENOMEM); + } - /* Initialize statistics */ - em_clear_hw_cntrs(&adapter->shared); - em_update_stats_counters(adapter); - adapter->shared.get_link_status = 1; - em_check_for_link(&adapter->shared); + /* Initialize the hardware */ + if (em_hardware_init(adapter)) { + printf("em%d: Unable to initialize the hardware\n", + adapter->unit); + em_free_pci_resources(adapter); + contigfree(adapter->tx_desc_base, tsize, M_DEVBUF); + contigfree(adapter->rx_desc_base, rsize, M_DEVBUF); + splx(s); + return(EIO); + } - /* Print the link status */ - if (adapter->link_active == 1) { - em_get_speed_and_duplex(&adapter->shared, &adapter->link_speed, &adapter->link_duplex); - printf("em%d: Speed:%d Mbps Duplex:%s\n", - adapter->unit, - adapter->link_speed, - adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half"); - } - else - printf("em%d: Speed:N/A Duplex:N/A\n", adapter->unit); + /* Setup OS specific network interface */ + em_setup_interface(dev, adapter); + /* Initialize statistics */ + em_clear_hw_cntrs(&adapter->hw); + em_update_stats_counters(adapter); + adapter->hw.get_link_status = 1; + em_check_for_link(&adapter->hw); - INIT_DEBUGOUT("em_attach: end"); - splx(s); - return(0); + /* Print the link status */ + if (adapter->link_active == 1) { + em_get_speed_and_duplex(&adapter->hw, &adapter->link_speed, + &adapter->link_duplex); + printf("em%d: Speed:%d Mbps Duplex:%s\n", + adapter->unit, + adapter->link_speed, + adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half"); + } else + printf("em%d: Speed:N/A Duplex:N/A\n", adapter->unit); + + + INIT_DEBUGOUT("em_attach: end"); + splx(s); + return(0); } /********************************************************************* * Device removal routine * * The detach entry point is called when the driver is being removed. * This routine stops the adapter and deallocates all the resources * that were allocated for driver operation. * * return 0 on success, positive on failure *********************************************************************/ static int em_detach(device_t dev) { - struct adapter * adapter = device_get_softc(dev); - struct ifnet *ifp = &adapter->interface_data.ac_if; - int s; - int size; + struct adapter * adapter = device_get_softc(dev); + struct ifnet *ifp = &adapter->interface_data.ac_if; + int s; + int size; - INIT_DEBUGOUT("em_detach: begin"); - s = splimp(); + INIT_DEBUGOUT("em_detach: begin"); + s = splimp(); - em_stop(adapter); - em_phy_hw_reset(&adapter->shared); - ether_ifdetach(&adapter->interface_data.ac_if, ETHER_BPF_SUPPORTED); - em_free_pci_resources(adapter); + em_stop(adapter); + em_phy_hw_reset(&adapter->hw); + ether_ifdetach(&adapter->interface_data.ac_if, ETHER_BPF_SUPPORTED); + em_free_pci_resources(adapter); - size = EM_ROUNDUP(adapter->num_tx_desc * - sizeof(struct em_tx_desc), 4096); + size = EM_ROUNDUP(adapter->num_tx_desc * + sizeof(struct em_tx_desc), 4096); - /* Free Transmit Descriptor ring */ - if (adapter->tx_desc_base) { - contigfree(adapter->tx_desc_base, size, M_DEVBUF); - adapter->tx_desc_base = NULL; - } + /* Free Transmit Descriptor ring */ + if (adapter->tx_desc_base) { + contigfree(adapter->tx_desc_base, size, M_DEVBUF); + adapter->tx_desc_base = NULL; + } - size = EM_ROUNDUP(adapter->num_rx_desc * - sizeof(struct em_rx_desc), 4096); + size = EM_ROUNDUP(adapter->num_rx_desc * + sizeof(struct em_rx_desc), 4096); - /* Free Receive Descriptor ring */ - if (adapter->rx_desc_base) { - contigfree(adapter->rx_desc_base, size, M_DEVBUF); - adapter->rx_desc_base = NULL; - } + /* Free Receive Descriptor ring */ + if (adapter->rx_desc_base) { + contigfree(adapter->rx_desc_base, size, M_DEVBUF); + adapter->rx_desc_base = NULL; + } - /* Remove from the adapter list */ - if(em_adapter_list == adapter) - em_adapter_list = adapter->next; - if(adapter->next != NULL) - adapter->next->prev = adapter->prev; - if(adapter->prev != NULL) - adapter->prev->next = adapter->next; + /* Remove from the adapter list */ + if (em_adapter_list == adapter) + em_adapter_list = adapter->next; + if (adapter->next != NULL) + adapter->next->prev = adapter->prev; + if (adapter->prev != NULL) + adapter->prev->next = adapter->next; - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); - ifp->if_timer = 0; + ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_timer = 0; - splx(s); - return(0); + splx(s); + return(0); } static int em_shutdown(device_t dev) { - struct adapter * adapter = device_get_softc(dev); - - /* Issue a global reset */ - em_adapter_stop(&adapter->shared); - return(0); + struct adapter *adapter = device_get_softc(dev); + em_stop(adapter); + return(0); } /********************************************************************* * Transmit entry point * * em_start is called by the stack to initiate a transmit. * The driver will remain in this routine as long as there are * packets to transmit and transmit resources are available. * In case resources are not available stack is notified and * the packet is requeued. **********************************************************************/ static void em_start(struct ifnet *ifp) { - int s; - struct mbuf *m_head, *mp; - vm_offset_t virtual_addr; - u_int32_t txd_upper; - u_int32_t txd_lower; - struct em_tx_buffer *tx_buffer; - struct em_tx_desc *current_tx_desc = NULL; - struct adapter * adapter = ifp->if_softc; + int s; + struct mbuf *m_head, *mp; + vm_offset_t virtual_addr; + u_int32_t txd_upper; + u_int32_t txd_lower; + struct em_tx_buffer *tx_buffer; + struct em_tx_desc *current_tx_desc = NULL; + struct adapter * adapter = ifp->if_softc; - if (!adapter->link_active) - return; + if (!adapter->link_active) + return; - s = splimp(); - while (ifp->if_snd.ifq_head != NULL) { + s = splimp(); + while (ifp->if_snd.ifq_head != NULL) { + struct ifvlan *ifv = NULL; - IF_DEQUEUE(&ifp->if_snd, m_head); - - if(m_head == NULL) break; + IF_DEQUEUE(&ifp->if_snd, m_head); - if (adapter->num_tx_desc_avail <= TX_CLEANUP_THRESHOLD) - em_clean_transmit_interrupts(adapter); + if (m_head == NULL) break; - if (adapter->num_tx_desc_avail <= TX_CLEANUP_THRESHOLD) { - ifp->if_flags |= IFF_OACTIVE; - IF_PREPEND(&ifp->if_snd, m_head); - adapter->no_tx_desc_avail++; - break; - } + if (adapter->num_tx_desc_avail <= TX_CLEANUP_THRESHOLD) + em_clean_transmit_interrupts(adapter); - tx_buffer = STAILQ_FIRST(&adapter->free_tx_buffer_list); - if (!tx_buffer) { - adapter->no_tx_buffer_avail1++; - - /* - * OK so we should not get here but I've seen it so lets try to - * clean up and then try to get a SwPacket again and only break - * if we still don't get one - */ - em_clean_transmit_interrupts(adapter); - tx_buffer = STAILQ_FIRST(&adapter->free_tx_buffer_list); - if (!tx_buffer) { - ifp->if_flags |= IFF_OACTIVE; - IF_PREPEND(&ifp->if_snd, m_head); - adapter->no_tx_buffer_avail2++; - break; - } - } - STAILQ_REMOVE_HEAD(&adapter->free_tx_buffer_list, em_tx_entry); + if (adapter->num_tx_desc_avail <= TX_CLEANUP_THRESHOLD) { + ifp->if_flags |= IFF_OACTIVE; + IF_PREPEND(&ifp->if_snd, m_head); + adapter->no_tx_desc_avail++; + break; + } - tx_buffer->num_tx_desc_used = 0; - tx_buffer->m_head = m_head; + tx_buffer = STAILQ_FIRST(&adapter->free_tx_buffer_list); + if (!tx_buffer) { + adapter->no_tx_buffer_avail1++; + /* + * OK so we should not get here but I've seen it so let + * us try to clean up and then try to get a tx_buffer + * again and only break if we still don't get one. + */ + em_clean_transmit_interrupts(adapter); + tx_buffer = STAILQ_FIRST(&adapter->free_tx_buffer_list); + if (!tx_buffer) { + ifp->if_flags |= IFF_OACTIVE; + IF_PREPEND(&ifp->if_snd, m_head); + adapter->no_tx_buffer_avail2++; + break; + } + } + STAILQ_REMOVE_HEAD(&adapter->free_tx_buffer_list, em_tx_entry); - if (ifp->if_hwassist > 0) { - em_transmit_checksum_setup(adapter, m_head, tx_buffer, &txd_upper, &txd_lower); - } else { - txd_upper = 0; - txd_lower = 0; - } + tx_buffer->num_tx_desc_used = 0; + tx_buffer->m_head = m_head; - for (mp = m_head; mp != NULL; mp = mp->m_next) { - if (mp->m_len == 0) - continue; - current_tx_desc = adapter->next_avail_tx_desc; - virtual_addr = mtod(mp, vm_offset_t); - current_tx_desc->buffer_addr = vtophys(virtual_addr); - - current_tx_desc->lower.data = (txd_lower | mp->m_len); - current_tx_desc->upper.data = (txd_upper); + if (ifp->if_hwassist > 0) { + em_transmit_checksum_setup(adapter, m_head, tx_buffer, + &txd_upper, &txd_lower); + } else { + txd_upper = 0; + txd_lower = 0; + } - if (current_tx_desc == adapter->last_tx_desc) - adapter->next_avail_tx_desc = - adapter->first_tx_desc; - else - adapter->next_avail_tx_desc++; + /* Find out if we are in vlan mode */ + if ((m_head->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) && + m_head->m_pkthdr.rcvif != NULL && + m_head->m_pkthdr.rcvif->if_type == IFT_L2VLAN) + ifv = m_head->m_pkthdr.rcvif->if_softc; - adapter->num_tx_desc_avail--; - tx_buffer->num_tx_desc_used++; - } - /* Put this tx_buffer at the end in the "in use" list */ - STAILQ_INSERT_TAIL(&adapter->used_tx_buffer_list, tx_buffer, em_tx_entry); + for (mp = m_head; mp != NULL; mp = mp->m_next) { + if (mp->m_len == 0) + continue; + current_tx_desc = adapter->next_avail_tx_desc; + virtual_addr = mtod(mp, vm_offset_t); + current_tx_desc->buffer_addr = vtophys(virtual_addr); - /* - * Last Descriptor of Packet needs End Of Packet (EOP), Report Status - * (RS) and append Ethernet CRC (IFCS) bits set. - */ - current_tx_desc->lower.data |= (adapter->txd_cmd | E1000_TXD_CMD_EOP); + current_tx_desc->lower.data = (txd_lower | mp->m_len); + current_tx_desc->upper.data = (txd_upper); - /* Send a copy of the frame to the BPF listener */ - if (ifp->if_bpf) - bpf_mtap(ifp, m_head); - /* - * Advance the Transmit Descriptor Tail (Tdt), this tells the E1000 - * that this frame is available to transmit. - */ - E1000_WRITE_REG(&adapter->shared, TDT, (((uintptr_t) adapter->next_avail_tx_desc - - (uintptr_t) adapter->first_tx_desc) >> 4)); - } /* end of while loop */ + if (current_tx_desc == adapter->last_tx_desc) + adapter->next_avail_tx_desc = + adapter->first_tx_desc; + else + adapter->next_avail_tx_desc++; - splx(s); + adapter->num_tx_desc_avail--; + tx_buffer->num_tx_desc_used++; + } - /* Set timeout in case chip has problems transmitting */ - ifp->if_timer = EM_TX_TIMEOUT; - - return; + /* Put this tx_buffer at the end in the "in use" list */ + STAILQ_INSERT_TAIL(&adapter->used_tx_buffer_list, tx_buffer, + em_tx_entry); + + if (ifv != NULL) { + /* Tell hardware to add tag */ + current_tx_desc->lower.data |= E1000_TXD_CMD_VLE; + + /* Set the vlan id */ + current_tx_desc->upper.fields.special = ifv->ifv_tag; + } + + /* + * Last Descriptor of Packet needs End Of Packet (EOP), Report Status + * (RS) and append Ethernet CRC (IFCS) bits set. + */ + current_tx_desc->lower.data |= (adapter->txd_cmd | E1000_TXD_CMD_EOP); + + /* Send a copy of the frame to the BPF listener */ + if (ifp->if_bpf) + bpf_mtap(ifp, m_head); + + /* + * Advance the Transmit Descriptor Tail (Tdt), this tells the E1000 + * that this frame is available to transmit. + */ + E1000_WRITE_REG(&adapter->hw, TDT, + (((uintptr_t) adapter->next_avail_tx_desc - + (uintptr_t) adapter->first_tx_desc) >> 4)); + } /* end of while loop */ + + splx(s); + + /* Set timeout in case chip has problems transmitting */ + ifp->if_timer = EM_TX_TIMEOUT; + + return; } /********************************************************************* * Ioctl entry point * * em_ioctl is called when the user wants to configure the * interface. * * return 0 on success, positive on failure **********************************************************************/ static int em_ioctl(struct ifnet *ifp, IOCTL_CMD_TYPE command, caddr_t data) { - int s, mask, error = 0; - struct ifreq *ifr = (struct ifreq *) data; - struct adapter * adapter = ifp->if_softc; + int s, mask, error = 0; + struct ifreq *ifr = (struct ifreq *) data; + struct adapter * adapter = ifp->if_softc; - s = splimp(); - switch (command) { - case SIOCSIFADDR: - case SIOCGIFADDR: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFADDR (Get/Set Interface Addr)"); - ether_ioctl(ifp, command, data); - break; - case SIOCSIFMTU: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFMTU (Set Interface MTU)"); - if (ifr->ifr_mtu > MAX_JUMBO_FRAME_SIZE - ETHER_HDR_LEN) { - error = EINVAL; - } else { - ifp->if_mtu = ifr->ifr_mtu; - adapter->shared.max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - em_init(adapter); - } - break; - case SIOCSIFFLAGS: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFFLAGS (Set Interface Flags)"); - if (ifp->if_flags & IFF_UP) { - if (ifp->if_flags & IFF_RUNNING && - ifp->if_flags & IFF_PROMISC) { - em_set_promisc(adapter); - } else if (ifp->if_flags & IFF_RUNNING && - !(ifp->if_flags & IFF_PROMISC)) { - em_disable_promisc(adapter); - } else - em_init(adapter); - } else { - if (ifp->if_flags & IFF_RUNNING) { - em_stop(adapter); - } - } - break; - case SIOCADDMULTI: - case SIOCDELMULTI: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI"); - if (ifp->if_flags & IFF_RUNNING) { - em_disable_intr(adapter); - em_set_multi(adapter); - if(adapter->shared.mac_type == em_82542_rev2_0) - em_initialize_receive_unit(adapter); - em_enable_intr(adapter); - } - break; - case SIOCSIFMEDIA: - case SIOCGIFMEDIA: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFMEDIA (Get/Set Interface Media)"); - error = ifmedia_ioctl(ifp, ifr, &adapter->media, command); - break; - case SIOCSIFCAP: - IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)"); - mask = ifr->ifr_reqcap ^ ifp->if_capenable; - if (mask & IFCAP_HWCSUM) { - if (IFCAP_HWCSUM & ifp->if_capenable) - ifp->if_capenable &= ~IFCAP_HWCSUM; - else - ifp->if_capenable |= IFCAP_HWCSUM; - if (ifp->if_flags & IFF_RUNNING) - em_init(adapter); - } - break; - default: - IOCTL_DEBUGOUT1("ioctl received: UNKNOWN (0x%d)\n", (int)command); - error = EINVAL; - } + s = splimp(); + switch (command) { + case SIOCSIFADDR: + case SIOCGIFADDR: + IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFADDR (Get/Set Interface Addr)"); + ether_ioctl(ifp, command, data); + break; + case SIOCSIFMTU: + IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFMTU (Set Interface MTU)"); + if (ifr->ifr_mtu > MAX_JUMBO_FRAME_SIZE - ETHER_HDR_LEN) { + error = EINVAL; + } else { + ifp->if_mtu = ifr->ifr_mtu; + adapter->hw.max_frame_size = + ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + em_init(adapter); + } + break; + case SIOCSIFFLAGS: + IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFFLAGS (Set Interface Flags)"); + if (ifp->if_flags & IFF_UP) { + if (ifp->if_flags & IFF_RUNNING && + ifp->if_flags & IFF_PROMISC) { + em_set_promisc(adapter); + } else if (ifp->if_flags & IFF_RUNNING && + !(ifp->if_flags & IFF_PROMISC)) { + em_disable_promisc(adapter); + } else + em_init(adapter); + } else { + if (ifp->if_flags & IFF_RUNNING) { + em_stop(adapter); + } + } + break; + case SIOCADDMULTI: + case SIOCDELMULTI: + IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI"); + if (ifp->if_flags & IFF_RUNNING) { + em_disable_intr(adapter); + em_set_multi(adapter); + if (adapter->hw.mac_type == em_82542_rev2_0) + em_initialize_receive_unit(adapter); + em_enable_intr(adapter); + } + break; + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + IOCTL_DEBUGOUT("ioctl rcv'd: SIOCxIFMEDIA (Get/Set Interface Media)"); + error = ifmedia_ioctl(ifp, ifr, &adapter->media, command); + break; + case SIOCSIFCAP: + IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)"); + mask = ifr->ifr_reqcap ^ ifp->if_capenable; + if (mask & IFCAP_HWCSUM) { + if (IFCAP_HWCSUM & ifp->if_capenable) + ifp->if_capenable &= ~IFCAP_HWCSUM; + else + ifp->if_capenable |= IFCAP_HWCSUM; + if (ifp->if_flags & IFF_RUNNING) + em_init(adapter); + } + break; + default: + IOCTL_DEBUGOUT1("ioctl received: UNKNOWN (0x%d)\n", (int)command); + error = EINVAL; + } - splx(s); - return(error); + splx(s); + return(error); } static void em_set_promisc(struct adapter * adapter) { - u_int32_t reg_rctl; - struct ifnet *ifp = &adapter->interface_data.ac_if; + u_int32_t reg_rctl; + struct ifnet *ifp = &adapter->interface_data.ac_if; - reg_rctl = E1000_READ_REG(&adapter->shared, RCTL); + reg_rctl = E1000_READ_REG(&adapter->hw, RCTL); - if(ifp->if_flags & IFF_PROMISC) { - reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); - } - else if (ifp->if_flags & IFF_ALLMULTI) { - reg_rctl |= E1000_RCTL_MPE; - reg_rctl &= ~E1000_RCTL_UPE; - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); - } + if (ifp->if_flags & IFF_PROMISC) { + reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); + } else if (ifp->if_flags & IFF_ALLMULTI) { + reg_rctl |= E1000_RCTL_MPE; + reg_rctl &= ~E1000_RCTL_UPE; + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); + } - return; + return; } static void em_disable_promisc(struct adapter * adapter) { - u_int32_t reg_rctl; + u_int32_t reg_rctl; - reg_rctl = E1000_READ_REG(&adapter->shared, RCTL); + reg_rctl = E1000_READ_REG(&adapter->hw, RCTL); - reg_rctl &= (~E1000_RCTL_UPE); - reg_rctl &= (~E1000_RCTL_MPE); - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); + reg_rctl &= (~E1000_RCTL_UPE); + reg_rctl &= (~E1000_RCTL_MPE); + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); - return; + return; } /********************************************************************* * Multicast Update * * This routine is called whenever multicast address list is updated. * **********************************************************************/ static void em_set_multi(struct adapter * adapter) { - u_int32_t reg_rctl = 0; - u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * ETH_LENGTH_OF_ADDRESS]; - u_int16_t pci_cmd_word; - struct ifmultiaddr *ifma; - int mcnt = 0; - struct ifnet *ifp = &adapter->interface_data.ac_if; + u_int32_t reg_rctl = 0; + u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * ETH_LENGTH_OF_ADDRESS]; + u_int16_t pci_cmd_word; + struct ifmultiaddr *ifma; + int mcnt = 0; + struct ifnet *ifp = &adapter->interface_data.ac_if; - IOCTL_DEBUGOUT("em_set_multi: begin"); - - if(adapter->shared.mac_type == em_82542_rev2_0) { - reg_rctl = E1000_READ_REG(&adapter->shared, RCTL); - if(adapter->shared.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) { - pci_cmd_word = adapter->shared.pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE; - pci_write_config(adapter->dev, PCIR_COMMAND, pci_cmd_word, 2); - } - reg_rctl |= E1000_RCTL_RST; - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); - msec_delay(5); - } + IOCTL_DEBUGOUT("em_set_multi: begin"); + if (adapter->hw.mac_type == em_82542_rev2_0) { + reg_rctl = E1000_READ_REG(&adapter->hw, RCTL); + if (adapter->hw.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) { + pci_cmd_word = adapter->hw.pci_cmd_word & + ~CMD_MEM_WRT_INVALIDATE; + pci_write_config(adapter->dev, PCIR_COMMAND, pci_cmd_word, 2); + } + reg_rctl |= E1000_RCTL_RST; + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); + msec_delay(5); + } + #if __FreeBSD_version < 500000 - LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { + LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { #else - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { + TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { #endif - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - - bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), - &mta[mcnt*ETH_LENGTH_OF_ADDRESS], ETH_LENGTH_OF_ADDRESS); - mcnt++; - } + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; - if (mcnt > MAX_NUM_MULTICAST_ADDRESSES) { - reg_rctl = E1000_READ_REG(&adapter->shared, RCTL); - reg_rctl |= E1000_RCTL_MPE; - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); - } - else - em_mc_addr_list_update(&adapter->shared, mta, mcnt, 0); + bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), + &mta[mcnt*ETH_LENGTH_OF_ADDRESS], ETH_LENGTH_OF_ADDRESS); + mcnt++; + } - if(adapter->shared.mac_type == em_82542_rev2_0) { - reg_rctl = E1000_READ_REG(&adapter->shared, RCTL); - reg_rctl &= ~E1000_RCTL_RST; - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); - msec_delay(5); - if(adapter->shared.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) { - pci_write_config(adapter->dev, PCIR_COMMAND, adapter->shared.pci_cmd_word, 2); - } - } + if (mcnt > MAX_NUM_MULTICAST_ADDRESSES) { + reg_rctl = E1000_READ_REG(&adapter->hw, RCTL); + reg_rctl |= E1000_RCTL_MPE; + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); + } else + em_mc_addr_list_update(&adapter->hw, mta, mcnt, 0); - return; + if (adapter->hw.mac_type == em_82542_rev2_0) { + reg_rctl = E1000_READ_REG(&adapter->hw, RCTL); + reg_rctl &= ~E1000_RCTL_RST; + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); + msec_delay(5); + if (adapter->hw.pci_cmd_word & CMD_MEM_WRT_INVALIDATE) { + pci_write_config(adapter->dev, PCIR_COMMAND, + adapter->hw.pci_cmd_word, 2); + } + } + + return; } /********************************************************************* * Watchdog entry point * * This routine is called whenever hardware quits transmitting. * **********************************************************************/ static void em_watchdog(struct ifnet *ifp) { - struct adapter * adapter; - adapter = ifp->if_softc; - - /* If we are in this routine because of pause frames, then - * don't reset the hardware. - */ - if(E1000_READ_REG(&adapter->shared, STATUS) & E1000_STATUS_TXOFF) { - ifp->if_timer = EM_TX_TIMEOUT; - return; - } + struct adapter * adapter; + adapter = ifp->if_softc; - printf("em%d: watchdog timeout -- resetting\n", adapter->unit); + /* If we are in this routine because of pause frames, then + * don't reset the hardware. + */ + if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_TXOFF) { + ifp->if_timer = EM_TX_TIMEOUT; + return; + } - ifp->if_flags &= ~IFF_RUNNING; + printf("em%d: watchdog timeout -- resetting\n", adapter->unit); - em_stop(adapter); - em_init(adapter); + ifp->if_flags &= ~IFF_RUNNING; - ifp->if_oerrors++; - return; + em_stop(adapter); + em_init(adapter); + + ifp->if_oerrors++; + return; } /********************************************************************* * Timer routine * * This routine checks for link status and updates statistics. * **********************************************************************/ static void em_local_timer(void *arg) { - int s; - struct ifnet *ifp; - struct adapter * adapter = arg; - ifp = &adapter->interface_data.ac_if; + int s; + struct ifnet *ifp; + struct adapter * adapter = arg; + ifp = &adapter->interface_data.ac_if; - s = splimp(); + s = splimp(); - em_check_for_link(&adapter->shared); - em_print_link_status(adapter); - em_update_stats_counters(adapter); - if(em_display_debug_stats && ifp->if_flags & IFF_RUNNING) { - em_print_hw_stats(adapter); - } - adapter->timer_handle = timeout(em_local_timer, adapter, 2*hz); + em_check_for_link(&adapter->hw); + em_print_link_status(adapter); + em_update_stats_counters(adapter); + if (em_display_debug_stats && ifp->if_flags & IFF_RUNNING) { + em_print_hw_stats(adapter); + } + adapter->timer_handle = timeout(em_local_timer, adapter, 2*hz); - splx(s); - return; + splx(s); + return; } static void em_print_link_status(struct adapter * adapter) { - if(E1000_READ_REG(&adapter->shared, STATUS) & E1000_STATUS_LU) { - if(adapter->link_active == 0) { - em_get_speed_and_duplex(&adapter->shared, &adapter->link_speed, &adapter->link_duplex); - printf("em%d: Link is up %d Mbps %s\n", - adapter->unit, - adapter->link_speed, - ((adapter->link_duplex == FULL_DUPLEX) ? - "Full Duplex" : "Half Duplex")); - adapter->link_active = 1; - } - } else { - if(adapter->link_active == 1) { - adapter->link_speed = 0; - adapter->link_duplex = 0; - printf("em%d: Link is Down\n", adapter->unit); - adapter->link_active = 0; - } - } + if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) { + if (adapter->link_active == 0) { + em_get_speed_and_duplex(&adapter->hw, + &adapter->link_speed, + &adapter->link_duplex); + printf("em%d: Link is up %d Mbps %s\n", + adapter->unit, + adapter->link_speed, + ((adapter->link_duplex == FULL_DUPLEX) ? + "Full Duplex" : "Half Duplex")); + adapter->link_active = 1; + } + } else { + if (adapter->link_active == 1) { + adapter->link_speed = 0; + adapter->link_duplex = 0; + printf("em%d: Link is Down\n", adapter->unit); + adapter->link_active = 0; + } + } - return; + return; } /********************************************************************* * Init entry point * * This routine is used in two ways. It is used by the stack as * init entry point in network interface structure. It is also used * by the driver as a hw/sw initialization routine to get to a * consistent state. * * return 0 on success, positive on failure **********************************************************************/ static void em_init(void *arg) { - int s; - struct ifnet *ifp; - struct adapter * adapter = arg; + int s; + struct ifnet *ifp; + struct adapter * adapter = arg; - INIT_DEBUGOUT("em_init: begin"); + INIT_DEBUGOUT("em_init: begin"); - s = splimp(); + s = splimp(); - em_stop(adapter); + em_stop(adapter); - /* Initialize the hardware */ - if (em_hardware_init(adapter)) { - printf("em%d: Unable to initialize the hardware\n", adapter->unit); - splx(s); - return; - } - adapter->shared.adapter_stopped = FALSE; - - /* Prepare transmit descriptors and buffers */ - if (em_setup_transmit_structures(adapter)) { - printf("em%d: Could not setup transmit structures\n", adapter->unit); - em_stop(adapter); - splx(s); - return; - } - em_initialize_transmit_unit(adapter); + /* Initialize the hardware */ + if (em_hardware_init(adapter)) { + printf("em%d: Unable to initialize the hardware\n", + adapter->unit); + splx(s); + return; + } - /* Setup Multicast table */ - em_set_multi(adapter); + em_enable_vlans(adapter); - /* Prepare receive descriptors and buffers */ - if (em_setup_receive_structures(adapter)) { - printf("em%d: Could not setup receive structures\n", adapter->unit); - em_stop(adapter); - splx(s); - return; - } - em_initialize_receive_unit(adapter); + /* Prepare transmit descriptors and buffers */ + if (em_setup_transmit_structures(adapter)) { + printf("em%d: Could not setup transmit structures\n", + adapter->unit); + em_stop(adapter); + splx(s); + return; + } + em_initialize_transmit_unit(adapter); - ifp = &adapter->interface_data.ac_if; - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + /* Setup Multicast table */ + em_set_multi(adapter); - if(adapter->shared.mac_type >= em_82543) { - if (ifp->if_capenable & IFCAP_TXCSUM) - ifp->if_hwassist = EM_CHECKSUM_FEATURES; - } + /* Prepare receive descriptors and buffers */ + if (em_setup_receive_structures(adapter)) { + printf("em%d: Could not setup receive structures\n", + adapter->unit); + em_stop(adapter); + splx(s); + return; + } + em_initialize_receive_unit(adapter); - adapter->timer_handle = timeout(em_local_timer, adapter, 2*hz); - em_clear_hw_cntrs(&adapter->shared); - em_enable_intr(adapter); + ifp = &adapter->interface_data.ac_if; + ifp->if_flags |= IFF_RUNNING; + ifp->if_flags &= ~IFF_OACTIVE; - splx(s); - return; + if (adapter->hw.mac_type >= em_82543) { + if (ifp->if_capenable & IFCAP_TXCSUM) + ifp->if_hwassist = EM_CHECKSUM_FEATURES; + else + ifp->if_hwassist = 0; + } + + adapter->timer_handle = timeout(em_local_timer, adapter, 2*hz); + em_clear_hw_cntrs(&adapter->hw); + em_enable_intr(adapter); + + splx(s); + return; } /********************************************************************* * * This routine disables all traffic on the adapter by issuing a * global reset on the MAC and deallocates TX/RX buffers. * **********************************************************************/ static void em_stop(void *arg) { - struct ifnet *ifp; - struct adapter * adapter = arg; - ifp = &adapter->interface_data.ac_if; + struct ifnet *ifp; + struct adapter * adapter = arg; + ifp = &adapter->interface_data.ac_if; - INIT_DEBUGOUT("em_stop: begin\n"); - em_disable_intr(adapter); - em_adapter_stop(&adapter->shared); - untimeout(em_local_timer, adapter, adapter->timer_handle); - em_free_transmit_structures(adapter); - em_free_receive_structures(adapter); + INIT_DEBUGOUT("em_stop: begin\n"); + em_disable_intr(adapter); + em_reset_hw(&adapter->hw); + untimeout(em_local_timer, adapter, adapter->timer_handle); + em_free_transmit_structures(adapter); + em_free_receive_structures(adapter); - /* Tell the stack that the interface is no longer active */ - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + /* Tell the stack that the interface is no longer active */ + ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); - return; + return; } /********************************************************************* * * Interrupt Service routine * **********************************************************************/ static void em_intr(void *arg) { - u_int32_t loop_cnt = EM_MAX_INTR; - u_int32_t reg_icr; - struct ifnet *ifp; - struct adapter *adapter = arg; + u_int32_t loop_cnt = EM_MAX_INTR; + u_int32_t reg_icr; + struct ifnet *ifp; + struct adapter *adapter = arg; - ifp = &adapter->interface_data.ac_if; + ifp = &adapter->interface_data.ac_if; - em_disable_intr(adapter); - while(loop_cnt > 0 && (reg_icr = E1000_READ_REG(&adapter->shared, ICR)) != 0) { + em_disable_intr(adapter); + while (loop_cnt > 0 && + (reg_icr = E1000_READ_REG(&adapter->hw, ICR)) != 0) { - /* Link status change */ - if(reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { - untimeout(em_local_timer, adapter, adapter->timer_handle); - adapter->shared.get_link_status = 1; - em_check_for_link(&adapter->shared); - em_print_link_status(adapter); - adapter->timer_handle = timeout(em_local_timer, adapter, 2*hz); - } + /* Link status change */ + if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { + untimeout(em_local_timer, adapter, + adapter->timer_handle); + adapter->hw.get_link_status = 1; + em_check_for_link(&adapter->hw); + em_print_link_status(adapter); + adapter->timer_handle = + timeout(em_local_timer, adapter, 2*hz); + } - if (ifp->if_flags & IFF_RUNNING) { - em_process_receive_interrupts(adapter); - em_clean_transmit_interrupts(adapter); - } - loop_cnt--; - } + if (ifp->if_flags & IFF_RUNNING) { + em_process_receive_interrupts(adapter); + em_clean_transmit_interrupts(adapter); + } + loop_cnt--; + } - em_enable_intr(adapter); + em_enable_intr(adapter); - if(ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL) - em_start(ifp); - - return; + if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL) + em_start(ifp); + + return; } /********************************************************************* * * Media Ioctl callback * * This routine is called whenever the user queries the status of * the interface using ifconfig. * **********************************************************************/ static void em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) { - struct adapter * adapter = ifp->if_softc; + struct adapter * adapter = ifp->if_softc; - INIT_DEBUGOUT("em_media_status: begin"); + INIT_DEBUGOUT("em_media_status: begin"); - em_check_for_link(&adapter->shared); - if(E1000_READ_REG(&adapter->shared, STATUS) & E1000_STATUS_LU) { - if(adapter->link_active == 0) { - em_get_speed_and_duplex(&adapter->shared, &adapter->link_speed, &adapter->link_duplex); - adapter->link_active = 1; - } - } - else { - if(adapter->link_active == 1) { - adapter->link_speed = 0; - adapter->link_duplex = 0; - adapter->link_active = 0; - } - } + em_check_for_link(&adapter->hw); + if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) { + if (adapter->link_active == 0) { + em_get_speed_and_duplex(&adapter->hw, + &adapter->link_speed, + &adapter->link_duplex); + adapter->link_active = 1; + } + } else { + if (adapter->link_active == 1) { + adapter->link_speed = 0; + adapter->link_duplex = 0; + adapter->link_active = 0; + } + } - ifmr->ifm_status = IFM_AVALID; - ifmr->ifm_active = IFM_ETHER; + ifmr->ifm_status = IFM_AVALID; + ifmr->ifm_active = IFM_ETHER; - if (!adapter->link_active) - return; + if (!adapter->link_active) + return; - ifmr->ifm_status |= IFM_ACTIVE; + ifmr->ifm_status |= IFM_ACTIVE; - if (adapter->shared.media_type == em_media_type_fiber) { - ifmr->ifm_active |= IFM_1000_SX | IFM_FDX; - } else { - switch (adapter->link_speed) { - case 10: - ifmr->ifm_active |= IFM_10_T; - break; - case 100: - ifmr->ifm_active |= IFM_100_TX; - break; - case 1000: - ifmr->ifm_active |= IFM_1000_TX; - break; - } - if (adapter->link_duplex == FULL_DUPLEX) - ifmr->ifm_active |= IFM_FDX; - else - ifmr->ifm_active |= IFM_HDX; - } - return; + if (adapter->hw.media_type == em_media_type_fiber) { + ifmr->ifm_active |= IFM_1000_SX | IFM_FDX; + } else { + switch (adapter->link_speed) { + case 10: + ifmr->ifm_active |= IFM_10_T; + break; + case 100: + ifmr->ifm_active |= IFM_100_TX; + break; + case 1000: + ifmr->ifm_active |= IFM_1000_TX; + break; + } + if (adapter->link_duplex == FULL_DUPLEX) + ifmr->ifm_active |= IFM_FDX; + else + ifmr->ifm_active |= IFM_HDX; + } + return; } /********************************************************************* * * Media Ioctl callback * * This routine is called when the user changes speed/duplex using * media/mediopt option with ifconfig. * **********************************************************************/ static int em_media_change(struct ifnet *ifp) { - struct adapter * adapter = ifp->if_softc; - struct ifmedia *ifm = &adapter->media; - - INIT_DEBUGOUT("em_media_change: begin"); + struct adapter * adapter = ifp->if_softc; + struct ifmedia *ifm = &adapter->media; - if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) - return(EINVAL); + INIT_DEBUGOUT("em_media_change: begin"); - switch(IFM_SUBTYPE(ifm->ifm_media)) { - case IFM_AUTO: - if (adapter->shared.autoneg) - return 0; - else { - adapter->shared.autoneg = DO_AUTO_NEG; - adapter->shared.autoneg_advertised = AUTONEG_ADV_DEFAULT; - } - break; - case IFM_1000_SX: - case IFM_1000_TX: - adapter->shared.autoneg = DO_AUTO_NEG; - adapter->shared.autoneg_advertised = ADVERTISE_1000_FULL; - break; - case IFM_100_TX: - adapter->shared.autoneg = FALSE; - adapter->shared.autoneg_advertised = 0; - if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) - adapter->shared.forced_speed_duplex = em_100_full; - else - adapter->shared.forced_speed_duplex = em_100_half; - break; - case IFM_10_T: - adapter->shared.autoneg = FALSE; - adapter->shared.autoneg_advertised = 0; - if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) - adapter->shared.forced_speed_duplex = em_10_full; - else - adapter->shared.forced_speed_duplex = em_10_half; - break; - default: - printf("em%d: Unsupported media type\n", adapter->unit); - } + if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) + return(EINVAL); - em_init(adapter); + switch (IFM_SUBTYPE(ifm->ifm_media)) { + case IFM_AUTO: + adapter->hw.autoneg = DO_AUTO_NEG; + adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; + break; + case IFM_1000_SX: + case IFM_1000_TX: + adapter->hw.autoneg = DO_AUTO_NEG; + adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL; + break; + case IFM_100_TX: + adapter->hw.autoneg = FALSE; + adapter->hw.autoneg_advertised = 0; + if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) + adapter->hw.forced_speed_duplex = em_100_full; + else + adapter->hw.forced_speed_duplex = em_100_half; + break; + case IFM_10_T: + adapter->hw.autoneg = FALSE; + adapter->hw.autoneg_advertised = 0; + if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) + adapter->hw.forced_speed_duplex = em_10_full; + else + adapter->hw.forced_speed_duplex = em_10_half; + break; + default: + printf("em%d: Unsupported media type\n", adapter->unit); + } - return(0); + em_init(adapter); + + return(0); } /* Section end: Other registered entry points */ /********************************************************************* * * Determine hardware revision. * **********************************************************************/ static void em_identify_hardware(struct adapter * adapter) { - device_t dev = adapter->dev; + device_t dev = adapter->dev; - /* Make sure our PCI config space has the necessary stuff set */ - adapter->shared.pci_cmd_word = pci_read_config(dev, PCIR_COMMAND, 2); - if (!((adapter->shared.pci_cmd_word & PCIM_CMD_BUSMASTEREN) && - (adapter->shared.pci_cmd_word & PCIM_CMD_MEMEN))) { - printf("em%d: Memory Access and/or Bus Master bits were not set!\n", - adapter->unit); - adapter->shared.pci_cmd_word |= (PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN); - pci_write_config(dev, PCIR_COMMAND, adapter->shared.pci_cmd_word, 2); - } + /* Make sure our PCI config space has the necessary stuff set */ + adapter->hw.pci_cmd_word = pci_read_config(dev, PCIR_COMMAND, 2); + if (!((adapter->hw.pci_cmd_word & PCIM_CMD_BUSMASTEREN) && + (adapter->hw.pci_cmd_word & PCIM_CMD_MEMEN))) { + printf("em%d: Memory Access and/or Bus Master bits were not set!\n", + adapter->unit); + adapter->hw.pci_cmd_word |= + (PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN); + pci_write_config(dev, PCIR_COMMAND, adapter->hw.pci_cmd_word, 2); + } - /* Save off the information about this board */ - adapter->shared.vendor_id = pci_get_vendor(dev); - adapter->shared.device_id = pci_get_device(dev); - adapter->shared.revision_id = pci_read_config(dev, PCIR_REVID, 1); - adapter->shared.subsystem_vendor_id = pci_read_config(dev, PCIR_SUBVEND_0, 2); - adapter->shared.subsystem_id = pci_read_config(dev, PCIR_SUBDEV_0, 2); + /* Save off the information about this board */ + adapter->hw.vendor_id = pci_get_vendor(dev); + adapter->hw.device_id = pci_get_device(dev); + adapter->hw.revision_id = pci_read_config(dev, PCIR_REVID, 1); + adapter->hw.subsystem_vendor_id = pci_read_config(dev, PCIR_SUBVEND_0, 2); + adapter->hw.subsystem_id = pci_read_config(dev, PCIR_SUBDEV_0, 2); - - /* Set MacType, etc. based on this PCI info */ - switch (adapter->shared.device_id) { - case E1000_DEV_ID_82542: - adapter->shared.mac_type = (adapter->shared.revision_id == 3) ? - em_82542_rev2_1 : em_82542_rev2_0; - break; - case E1000_DEV_ID_82543GC_FIBER: - case E1000_DEV_ID_82543GC_COPPER: - adapter->shared.mac_type = em_82543; - break; - case E1000_DEV_ID_82544EI_FIBER: - case E1000_DEV_ID_82544EI_COPPER: - case E1000_DEV_ID_82544GC_COPPER: - case E1000_DEV_ID_82544GC_LOM: - adapter->shared.mac_type = em_82544; - break; - case E1000_DEV_ID_82540EM: - adapter->shared.mac_type = em_82540; - default: - INIT_DEBUGOUT1("Unknown device id 0x%x", adapter->shared.device_id); - } - return; + + /* Set MacType, etc. based on this PCI info */ + switch (adapter->hw.device_id) { + case E1000_DEV_ID_82542: + adapter->hw.mac_type = (adapter->hw.revision_id == 3) ? + em_82542_rev2_1 : em_82542_rev2_0; + break; + case E1000_DEV_ID_82543GC_FIBER: + case E1000_DEV_ID_82543GC_COPPER: + adapter->hw.mac_type = em_82543; + break; + case E1000_DEV_ID_82544EI_FIBER: + case E1000_DEV_ID_82544EI_COPPER: + case E1000_DEV_ID_82544GC_COPPER: + case E1000_DEV_ID_82544GC_LOM: + adapter->hw.mac_type = em_82544; + break; + case E1000_DEV_ID_82540EM: + adapter->hw.mac_type = em_82540; + break; + case E1000_DEV_ID_82545EM_FIBER: + case E1000_DEV_ID_82545EM_COPPER: + adapter->hw.mac_type = em_82545; + break; + case E1000_DEV_ID_82546EB_FIBER: + case E1000_DEV_ID_82546EB_COPPER: + adapter->hw.mac_type = em_82546; + break; + default: + INIT_DEBUGOUT1("Unknown device id 0x%x", adapter->hw.device_id); + } + return; } static int em_allocate_pci_resources(struct adapter * adapter) { - int resource_id = EM_MMBA; - device_t dev = adapter->dev; + int resource_id = EM_MMBA; + device_t dev = adapter->dev; - adapter->res_memory = bus_alloc_resource(dev, SYS_RES_MEMORY, - &resource_id, 0, ~0, 1, - RF_ACTIVE); - if (!(adapter->res_memory)) { - printf("em%d: Unable to allocate bus resource: memory\n", adapter->unit); - return(ENXIO); - } - adapter->osdep.bus_space_tag = rman_get_bustag(adapter->res_memory); - adapter->osdep.bus_space_handle = rman_get_bushandle(adapter->res_memory); - adapter->shared.hw_addr = (uint8_t *)adapter->osdep.bus_space_handle; + adapter->res_memory = bus_alloc_resource(dev, SYS_RES_MEMORY, + &resource_id, 0, ~0, 1, + RF_ACTIVE); + if (!(adapter->res_memory)) { + printf("em%d: Unable to allocate bus resource: memory\n", + adapter->unit); + return(ENXIO); + } + adapter->osdep.bus_space_tag = + rman_get_bustag(adapter->res_memory); + adapter->osdep.bus_space_handle = + rman_get_bushandle(adapter->res_memory); + adapter->hw.hw_addr = (uint8_t *)&adapter->osdep.bus_space_handle; - resource_id = 0x0; - adapter->res_interrupt = bus_alloc_resource(dev, SYS_RES_IRQ, - &resource_id, 0, ~0, 1, - RF_SHAREABLE | RF_ACTIVE); - if (!(adapter->res_interrupt)) { - printf("em%d: Unable to allocate bus resource: interrupt\n", adapter->unit); - return(ENXIO); - } - if (bus_setup_intr(dev, adapter->res_interrupt, INTR_TYPE_NET, - (void (*)(void *)) em_intr, adapter, - &adapter->int_handler_tag)) { - printf("em%d: Error registering interrupt handler!\n", adapter->unit); - return(ENXIO); - } + resource_id = 0x0; + adapter->res_interrupt = bus_alloc_resource(dev, SYS_RES_IRQ, + &resource_id, 0, ~0, 1, + RF_SHAREABLE | RF_ACTIVE); + if (!(adapter->res_interrupt)) { + printf("em%d: Unable to allocate bus resource: interrupt\n", + adapter->unit); + return(ENXIO); + } + if (bus_setup_intr(dev, adapter->res_interrupt, INTR_TYPE_NET, + (void (*)(void *)) em_intr, adapter, + &adapter->int_handler_tag)) { + printf("em%d: Error registering interrupt handler!\n", + adapter->unit); + return(ENXIO); + } - adapter->shared.back = &adapter->osdep; + adapter->hw.back = &adapter->osdep; - return(0); + return(0); } static void em_free_pci_resources(struct adapter * adapter) { - device_t dev = adapter->dev; + device_t dev = adapter->dev; - if(adapter->res_interrupt != NULL) { - bus_teardown_intr(dev, adapter->res_interrupt, adapter->int_handler_tag); - bus_release_resource(dev, SYS_RES_IRQ, 0, adapter->res_interrupt); - } - if (adapter->res_memory != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, EM_MMBA, adapter->res_memory); - } - return; + if (adapter->res_interrupt != NULL) { + bus_teardown_intr(dev, adapter->res_interrupt, + adapter->int_handler_tag); + bus_release_resource(dev, SYS_RES_IRQ, 0, + adapter->res_interrupt); + } + if (adapter->res_memory != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, EM_MMBA, + adapter->res_memory); + } + return; } /********************************************************************* * * Initialize the hardware to a configuration as specified by the * adapter structure. The controller is reset, the EEPROM is * verified, the MAC address is set, then the shared initialization * routines are called. * **********************************************************************/ static int em_hardware_init(struct adapter * adapter) { - /* Issue a global reset */ - adapter->shared.adapter_stopped = FALSE; - em_adapter_stop(&adapter->shared); - adapter->shared.adapter_stopped = FALSE; + /* Issue a global reset */ + em_reset_hw(&adapter->hw); - /* Make sure we have a good EEPROM before we read from it */ - if (!em_validate_eeprom_checksum(&adapter->shared)) { - printf("em%d: The EEPROM Checksum Is Not Valid\n", adapter->unit); - return EIO; - } - /* Copy the permanent MAC address and part number out of the EEPROM */ - em_read_mac_address(adapter, adapter->interface_data.ac_enaddr); - memcpy(adapter->shared.mac_addr, adapter->interface_data.ac_enaddr, - ETH_LENGTH_OF_ADDRESS); - em_read_part_num(&adapter->shared, &(adapter->part_num)); + /* Make sure we have a good EEPROM before we read from it */ + if (em_validate_eeprom_checksum(&adapter->hw) < 0) { + printf("em%d: The EEPROM Checksum Is Not Valid\n", + adapter->unit); + return(EIO); + } + /* Copy the permanent MAC address and part number out of the EEPROM */ + if (em_read_mac_addr(&adapter->hw) < 0) { + printf("em%d: EEPROM read error while reading mac address\n", + adapter->unit); + return(EIO); + } - if (!em_init_hw(&adapter->shared)) { - printf("em%d: Hardware Initialization Failed", adapter->unit); - return EIO; - } + memcpy(adapter->interface_data.ac_enaddr, adapter->hw.mac_addr, + ETH_LENGTH_OF_ADDRESS); - em_check_for_link(&adapter->shared); - if (E1000_READ_REG(&adapter->shared, STATUS) & E1000_STATUS_LU) - adapter->link_active = 1; - else - adapter->link_active = 0; - - if (adapter->link_active) { - em_get_speed_and_duplex(&adapter->shared, &adapter->link_speed, &adapter->link_duplex); - } else { - adapter->link_speed = 0; - adapter->link_duplex = 0; - } - return 0; -} + if (em_read_part_num(&adapter->hw, &(adapter->part_num)) < 0) { + printf("em%d: EEPROM read error while reading part number\n", + adapter->unit); + return(EIO); + } -static void -em_read_mac_address(struct adapter * adapter, u_int8_t * NodeAddress) -{ - u_int16_t EepromWordValue; - int i; + if (em_init_hw(&adapter->hw) < 0) { + printf("em%d: Hardware Initialization Failed", + adapter->unit); + return(EIO); + } - for (i = 0; i < NODE_ADDRESS_SIZE; i += 2) { - EepromWordValue = - em_read_eeprom(&adapter->shared, EEPROM_NODE_ADDRESS_BYTE_0 + (i / 2)); - NodeAddress[i] = (uint8_t) (EepromWordValue & 0x00FF); - NodeAddress[i + 1] = (uint8_t) (EepromWordValue >> 8); - } + em_check_for_link(&adapter->hw); + if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) + adapter->link_active = 1; + else + adapter->link_active = 0; - return; + if (adapter->link_active) { + em_get_speed_and_duplex(&adapter->hw, + &adapter->link_speed, + &adapter->link_duplex); + } else { + adapter->link_speed = 0; + adapter->link_duplex = 0; + } + + return(0); } /********************************************************************* * * Setup networking device structure and register an interface. * **********************************************************************/ static void em_setup_interface(device_t dev, struct adapter * adapter) { - struct ifnet *ifp; - INIT_DEBUGOUT("em_setup_interface: begin"); + struct ifnet *ifp; + INIT_DEBUGOUT("em_setup_interface: begin"); - ifp = &adapter->interface_data.ac_if; - ifp->if_unit = adapter->unit; - ifp->if_name = "em"; - ifp->if_mtu = ETHERMTU; - ifp->if_output = ether_output; - ifp->if_baudrate = 1000000000; - ifp->if_init = em_init; - ifp->if_softc = adapter; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = em_ioctl; - ifp->if_start = em_start; - ifp->if_watchdog = em_watchdog; - ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1; - ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + ifp = &adapter->interface_data.ac_if; + ifp->if_unit = adapter->unit; + ifp->if_name = "em"; + ifp->if_mtu = ETHERMTU; + ifp->if_output = ether_output; + ifp->if_baudrate = 1000000000; + ifp->if_init = em_init; + ifp->if_softc = adapter; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_ioctl = em_ioctl; + ifp->if_start = em_start; + ifp->if_watchdog = em_watchdog; + ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1; + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); - if (adapter->shared.mac_type >= em_82543) { - ifp->if_capabilities = IFCAP_HWCSUM; - ifp->if_capenable = ifp->if_capabilities; - } + if (adapter->hw.mac_type >= em_82543) { + ifp->if_capabilities = IFCAP_HWCSUM; + ifp->if_capenable = ifp->if_capabilities; + } - /* - * Specify the media types supported by this adapter and register - * callbacks to update media and link information - */ - ifmedia_init(&adapter->media, IFM_IMASK, em_media_change, - em_media_status); - if (adapter->shared.media_type == em_media_type_fiber) { - ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_SX | IFM_FDX, 0, - NULL); - ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_SX , 0, NULL); - } else { - ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T, 0, NULL); - ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, - NULL); - ifmedia_add(&adapter->media, IFM_ETHER | IFM_100_TX, 0, NULL); - ifmedia_add(&adapter->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, - NULL); - ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_TX | IFM_FDX, 0, - NULL); - ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_TX, 0, NULL); - } - ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + /* + * Specify the media types supported by this adapter and register + * callbacks to update media and link information + */ + ifmedia_init(&adapter->media, IFM_IMASK, em_media_change, + em_media_status); + if (adapter->hw.media_type == em_media_type_fiber) { + ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_SX | IFM_FDX, + 0, NULL); + ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_SX, + 0, NULL); + } else { + ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T, 0, NULL); + ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T | IFM_FDX, + 0, NULL); + ifmedia_add(&adapter->media, IFM_ETHER | IFM_100_TX, + 0, NULL); + ifmedia_add(&adapter->media, IFM_ETHER | IFM_100_TX | IFM_FDX, + 0, NULL); + ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_TX | IFM_FDX, + 0, NULL); + ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_TX, 0, NULL); + } + ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); - return; + return; } /********************************************************************* * * Allocate memory for tx_buffer structures. The tx_buffer stores all * the information needed to transmit a packet on the wire. * **********************************************************************/ static int em_allocate_transmit_structures(struct adapter * adapter) { - if (!(adapter->tx_buffer_area = - (struct em_tx_buffer *) malloc(sizeof(struct em_tx_buffer) * - adapter->num_tx_desc, M_DEVBUF, - M_NOWAIT))) { - printf("em%d: Unable to allocate tx_buffer memory\n", adapter->unit); - return ENOMEM; - } + if (!(adapter->tx_buffer_area = + (struct em_tx_buffer *) malloc(sizeof(struct em_tx_buffer) * + adapter->num_tx_desc, M_DEVBUF, + M_NOWAIT))) { + printf("em%d: Unable to allocate tx_buffer memory\n", + adapter->unit); + return ENOMEM; + } - bzero(adapter->tx_buffer_area, - sizeof(struct em_tx_buffer) * adapter->num_tx_desc); + bzero(adapter->tx_buffer_area, + sizeof(struct em_tx_buffer) * adapter->num_tx_desc); - return 0; + return 0; } /********************************************************************* * * Allocate and initialize transmit structures. * **********************************************************************/ static int em_setup_transmit_structures(struct adapter * adapter) { - struct em_tx_buffer *tx_buffer; - int i; + struct em_tx_buffer *tx_buffer; + int i; - if (em_allocate_transmit_structures(adapter)) - return ENOMEM; + if (em_allocate_transmit_structures(adapter)) + return ENOMEM; - adapter->first_tx_desc = adapter->tx_desc_base; - adapter->last_tx_desc = - adapter->first_tx_desc + (adapter->num_tx_desc - 1); + adapter->first_tx_desc = adapter->tx_desc_base; + adapter->last_tx_desc = + adapter->first_tx_desc + (adapter->num_tx_desc - 1); - - STAILQ_INIT(&adapter->free_tx_buffer_list); - STAILQ_INIT(&adapter->used_tx_buffer_list); - tx_buffer = adapter->tx_buffer_area; + STAILQ_INIT(&adapter->free_tx_buffer_list); + STAILQ_INIT(&adapter->used_tx_buffer_list); - /* Setup the linked list of the tx_buffer's */ - for (i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) { - bzero((void *) tx_buffer, sizeof(struct em_tx_buffer)); - STAILQ_INSERT_TAIL(&adapter->free_tx_buffer_list, tx_buffer, em_tx_entry); - } + tx_buffer = adapter->tx_buffer_area; - bzero((void *) adapter->first_tx_desc, - (sizeof(struct em_tx_desc)) * adapter->num_tx_desc); + /* Setup the linked list of the tx_buffer's */ + for (i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) { + bzero((void *) tx_buffer, sizeof(struct em_tx_buffer)); + STAILQ_INSERT_TAIL(&adapter->free_tx_buffer_list, + tx_buffer, em_tx_entry); + } - /* Setup TX descriptor pointers */ - adapter->next_avail_tx_desc = adapter->first_tx_desc; - adapter->oldest_used_tx_desc = adapter->first_tx_desc; + bzero((void *) adapter->first_tx_desc, + (sizeof(struct em_tx_desc)) * adapter->num_tx_desc); - /* Set number of descriptors available */ - adapter->num_tx_desc_avail = adapter->num_tx_desc; + /* Setup TX descriptor pointers */ + adapter->next_avail_tx_desc = adapter->first_tx_desc; + adapter->oldest_used_tx_desc = adapter->first_tx_desc; - /* Set checksum context */ - adapter->active_checksum_context = OFFLOAD_NONE; + /* Set number of descriptors available */ + adapter->num_tx_desc_avail = adapter->num_tx_desc; - return 0; + /* Set checksum context */ + adapter->active_checksum_context = OFFLOAD_NONE; + + return 0; } /********************************************************************* * * Enable transmit unit. * **********************************************************************/ static void em_initialize_transmit_unit(struct adapter * adapter) { - u_int32_t reg_tctl; - u_int32_t reg_tipg = 0; + u_int32_t reg_tctl; + u_int32_t reg_tipg = 0; - /* Setup the Base and Length of the Tx Descriptor Ring */ - E1000_WRITE_REG(&adapter->shared, TDBAL, vtophys((vm_offset_t) adapter->tx_desc_base)); - E1000_WRITE_REG(&adapter->shared, TDBAH, 0); - E1000_WRITE_REG(&adapter->shared, TDLEN, adapter->num_tx_desc * - sizeof(struct em_tx_desc)); + /* Setup the Base and Length of the Tx Descriptor Ring */ + E1000_WRITE_REG(&adapter->hw, TDBAL, + vtophys((vm_offset_t) adapter->tx_desc_base)); + E1000_WRITE_REG(&adapter->hw, TDBAH, 0); + E1000_WRITE_REG(&adapter->hw, TDLEN, + adapter->num_tx_desc * + sizeof(struct em_tx_desc)); - /* Setup the HW Tx Head and Tail descriptor pointers */ - E1000_WRITE_REG(&adapter->shared, TDH, 0); - E1000_WRITE_REG(&adapter->shared, TDT, 0); + /* Setup the HW Tx Head and Tail descriptor pointers */ + E1000_WRITE_REG(&adapter->hw, TDH, 0); + E1000_WRITE_REG(&adapter->hw, TDT, 0); - HW_DEBUGOUT2("Base = %x, Length = %x\n", E1000_READ_REG(&adapter->shared, TDBAL), - E1000_READ_REG(&adapter->shared, TDLEN)); + HW_DEBUGOUT2("Base = %x, Length = %x\n", + E1000_READ_REG(&adapter->hw, TDBAL), + E1000_READ_REG(&adapter->hw, TDLEN)); - - /* Set the default values for the Tx Inter Packet Gap timer */ - switch (adapter->shared.mac_type) { - case em_82543: - case em_82544: - case em_82540: - if (adapter->shared.media_type == em_media_type_fiber) - reg_tipg = DEFAULT_82543_TIPG_IPGT_FIBER; - else - reg_tipg = DEFAULT_82543_TIPG_IPGT_COPPER; - reg_tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT; - reg_tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT; - break; - case em_82542_rev2_0: - case em_82542_rev2_1: - reg_tipg = DEFAULT_82542_TIPG_IPGT; - reg_tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT; - reg_tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT; - break; - default: - printf("em%d: Invalid mac type detected\n", adapter->unit); - } - E1000_WRITE_REG(&adapter->shared, TIPG, reg_tipg); - E1000_WRITE_REG(&adapter->shared, TIDV, adapter->tx_int_delay); - /* Program the Transmit Control Register */ - reg_tctl = E1000_TCTL_PSP | E1000_TCTL_EN | - (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); - if (adapter->link_duplex == 1) { - reg_tctl |= E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT; - } else { - reg_tctl |= E1000_HDX_COLLISION_DISTANCE << E1000_COLD_SHIFT; - } - E1000_WRITE_REG(&adapter->shared, TCTL, reg_tctl); + /* Set the default values for the Tx Inter Packet Gap timer */ + switch (adapter->hw.mac_type) { + case em_82543: + case em_82544: + case em_82540: + case em_82545: + case em_82546: + if (adapter->hw.media_type == em_media_type_fiber) + reg_tipg = DEFAULT_82543_TIPG_IPGT_FIBER; + else + reg_tipg = DEFAULT_82543_TIPG_IPGT_COPPER; + reg_tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT; + reg_tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT; + break; + case em_82542_rev2_0: + case em_82542_rev2_1: + reg_tipg = DEFAULT_82542_TIPG_IPGT; + reg_tipg |= DEFAULT_82542_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT; + reg_tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT; + break; + default: + printf("em%d: Invalid mac type detected\n", adapter->unit); + } + E1000_WRITE_REG(&adapter->hw, TIPG, reg_tipg); + E1000_WRITE_REG(&adapter->hw, TIDV, adapter->tx_int_delay); - /* Setup Transmit Descriptor Settings for this adapter */ - adapter->txd_cmd = E1000_TXD_CMD_IFCS; + /* Program the Transmit Control Register */ + reg_tctl = E1000_TCTL_PSP | E1000_TCTL_EN | + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); + if (adapter->link_duplex == 1) { + reg_tctl |= E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT; + } else { + reg_tctl |= E1000_HDX_COLLISION_DISTANCE << E1000_COLD_SHIFT; + } + E1000_WRITE_REG(&adapter->hw, TCTL, reg_tctl); - if(adapter->tx_int_delay > 0) - adapter->txd_cmd |= E1000_TXD_CMD_IDE; - - if(adapter->shared.report_tx_early == 1) - adapter->txd_cmd |= E1000_TXD_CMD_RS; - else - adapter->txd_cmd |= E1000_TXD_CMD_RPS; + /* Setup Transmit Descriptor Settings for this adapter */ + adapter->txd_cmd = E1000_TXD_CMD_IFCS; - return; + if (adapter->tx_int_delay > 0) + adapter->txd_cmd |= E1000_TXD_CMD_IDE; + + if (adapter->hw.report_tx_early == 1) + adapter->txd_cmd |= E1000_TXD_CMD_RS; + else + adapter->txd_cmd |= E1000_TXD_CMD_RPS; + + return; } /********************************************************************* * * Free all transmit related data structures. * **********************************************************************/ static void em_free_transmit_structures(struct adapter * adapter) { - struct em_tx_buffer *tx_buffer; - int i; + struct em_tx_buffer *tx_buffer; + int i; - INIT_DEBUGOUT("free_transmit_structures: begin"); + INIT_DEBUGOUT("free_transmit_structures: begin"); - if (adapter->tx_buffer_area != NULL) { - tx_buffer = adapter->tx_buffer_area; - for (i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) { - if (tx_buffer->m_head != NULL) - m_freem(tx_buffer->m_head); - tx_buffer->m_head = NULL; - } - } - if (adapter->tx_buffer_area != NULL) { - free(adapter->tx_buffer_area, M_DEVBUF); - adapter->tx_buffer_area = NULL; - } - return; + if (adapter->tx_buffer_area != NULL) { + tx_buffer = adapter->tx_buffer_area; + for (i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) { + if (tx_buffer->m_head != NULL) + m_freem(tx_buffer->m_head); + tx_buffer->m_head = NULL; + } + } + if (adapter->tx_buffer_area != NULL) { + free(adapter->tx_buffer_area, M_DEVBUF); + adapter->tx_buffer_area = NULL; + } + return; } /********************************************************************* * * The offload context needs to be set when we transfer the first * packet of a particular protocol (TCP/UDP). We change the * context only if the protocol type changes. * **********************************************************************/ static void em_transmit_checksum_setup(struct adapter * adapter, - struct mbuf *mp, - struct em_tx_buffer *tx_buffer, - u_int32_t *txd_upper, - u_int32_t *txd_lower) + struct mbuf *mp, + struct em_tx_buffer *tx_buffer, + u_int32_t *txd_upper, + u_int32_t *txd_lower) { - struct em_context_desc *TXD; - struct em_tx_desc * current_tx_desc; - - if (mp->m_pkthdr.csum_flags) { + struct em_context_desc *TXD; + struct em_tx_desc * current_tx_desc; - if(mp->m_pkthdr.csum_flags & CSUM_TCP) { - *txd_upper = E1000_TXD_POPTS_TXSM << 8; - *txd_lower = E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D; - if(adapter->active_checksum_context == OFFLOAD_TCP_IP) - return; - else - adapter->active_checksum_context = OFFLOAD_TCP_IP; + if (mp->m_pkthdr.csum_flags) { - } else if(mp->m_pkthdr.csum_flags & CSUM_UDP) { - *txd_upper = E1000_TXD_POPTS_TXSM << 8; - *txd_lower = E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D; - if(adapter->active_checksum_context == OFFLOAD_UDP_IP) - return; - else - adapter->active_checksum_context = OFFLOAD_UDP_IP; - } else { - *txd_upper = 0; - *txd_lower = 0; - return; - } - } - else { - *txd_upper = 0; - *txd_lower = 0; - return; - } + if (mp->m_pkthdr.csum_flags & CSUM_TCP) { + *txd_upper = E1000_TXD_POPTS_TXSM << 8; + *txd_lower = E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D; + if (adapter->active_checksum_context == OFFLOAD_TCP_IP) + return; + else + adapter->active_checksum_context = OFFLOAD_TCP_IP; - /* If we reach this point, the checksum offload context - * needs to be reset. - */ - current_tx_desc = adapter->next_avail_tx_desc; - TXD = (struct em_context_desc *)current_tx_desc; + } else if (mp->m_pkthdr.csum_flags & CSUM_UDP) { + *txd_upper = E1000_TXD_POPTS_TXSM << 8; + *txd_lower = E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D; + if (adapter->active_checksum_context == OFFLOAD_UDP_IP) + return; + else + adapter->active_checksum_context = OFFLOAD_UDP_IP; + } else { + *txd_upper = 0; + *txd_lower = 0; + return; + } + } else { + *txd_upper = 0; + *txd_lower = 0; + return; + } - TXD->lower_setup.ip_fields.ipcss = ETHER_HDR_LEN; - TXD->lower_setup.ip_fields.ipcso = ETHER_HDR_LEN + offsetof(struct ip, ip_sum); - TXD->lower_setup.ip_fields.ipcse = ETHER_HDR_LEN + sizeof(struct ip) - 1; + /* If we reach this point, the checksum offload context + * needs to be reset. + */ + current_tx_desc = adapter->next_avail_tx_desc; + TXD = (struct em_context_desc *)current_tx_desc; - TXD->upper_setup.tcp_fields.tucss = ETHER_HDR_LEN + sizeof(struct ip); - TXD->upper_setup.tcp_fields.tucse = 0; + TXD->lower_setup.ip_fields.ipcss = ETHER_HDR_LEN; + TXD->lower_setup.ip_fields.ipcso = + ETHER_HDR_LEN + offsetof(struct ip, ip_sum); + TXD->lower_setup.ip_fields.ipcse = + ETHER_HDR_LEN + sizeof(struct ip) - 1; - if(adapter->active_checksum_context == OFFLOAD_TCP_IP) { - TXD->upper_setup.tcp_fields.tucso = ETHER_HDR_LEN + sizeof(struct ip) + - offsetof(struct tcphdr, th_sum); - } else if (adapter->active_checksum_context == OFFLOAD_UDP_IP) { - TXD->upper_setup.tcp_fields.tucso = ETHER_HDR_LEN + sizeof(struct ip) + - offsetof(struct udphdr, uh_sum); - } + TXD->upper_setup.tcp_fields.tucss = + ETHER_HDR_LEN + sizeof(struct ip); + TXD->upper_setup.tcp_fields.tucse = 0; - TXD->tcp_seg_setup.data = 0; - TXD->cmd_and_length = E1000_TXD_CMD_DEXT; + if (adapter->active_checksum_context == OFFLOAD_TCP_IP) { + TXD->upper_setup.tcp_fields.tucso = + ETHER_HDR_LEN + sizeof(struct ip) + + offsetof(struct tcphdr, th_sum); + } else if (adapter->active_checksum_context == OFFLOAD_UDP_IP) { + TXD->upper_setup.tcp_fields.tucso = + ETHER_HDR_LEN + sizeof(struct ip) + + offsetof(struct udphdr, uh_sum); + } - if (current_tx_desc == adapter->last_tx_desc) - adapter->next_avail_tx_desc = adapter->first_tx_desc; - else - adapter->next_avail_tx_desc++; + TXD->tcp_seg_setup.data = 0; + TXD->cmd_and_length = E1000_TXD_CMD_DEXT; - adapter->num_tx_desc_avail--; - - tx_buffer->num_tx_desc_used++; - return; + if (current_tx_desc == adapter->last_tx_desc) + adapter->next_avail_tx_desc = adapter->first_tx_desc; + else + adapter->next_avail_tx_desc++; + + adapter->num_tx_desc_avail--; + + tx_buffer->num_tx_desc_used++; + return; } /********************************************************************* * * Get a buffer from system mbuf buffer pool. * **********************************************************************/ static int em_get_buf(struct em_rx_buffer *rx_buffer, struct adapter *adapter, - struct mbuf *mp) + struct mbuf *mp) { - struct mbuf *nmp; - struct ifnet *ifp; + struct mbuf *nmp; + struct ifnet *ifp; - ifp = &adapter->interface_data.ac_if; + ifp = &adapter->interface_data.ac_if; - if (mp == NULL) { - MGETHDR(nmp, M_DONTWAIT, MT_DATA); - if (nmp == NULL) { - adapter->mbuf_alloc_failed++; - return (ENOBUFS); - } - MCLGET(nmp, M_DONTWAIT); - if ((nmp->m_flags & M_EXT) == 0) { - m_freem(nmp); - adapter->mbuf_cluster_failed++; - return (ENOBUFS); - } - nmp->m_len = nmp->m_pkthdr.len = MCLBYTES; - } else { - nmp = mp; - nmp->m_len = nmp->m_pkthdr.len = MCLBYTES; - nmp->m_data = nmp->m_ext.ext_buf; - nmp->m_next = NULL; - } + if (mp == NULL) { + MGETHDR(nmp, M_DONTWAIT, MT_DATA); + if (nmp == NULL) { + adapter->mbuf_alloc_failed++; + return(ENOBUFS); + } + MCLGET(nmp, M_DONTWAIT); + if ((nmp->m_flags & M_EXT) == 0) { + m_freem(nmp); + adapter->mbuf_cluster_failed++; + return(ENOBUFS); + } + nmp->m_len = nmp->m_pkthdr.len = MCLBYTES; + } else { + nmp = mp; + nmp->m_len = nmp->m_pkthdr.len = MCLBYTES; + nmp->m_data = nmp->m_ext.ext_buf; + nmp->m_next = NULL; + } - if (ifp->if_mtu <= ETHERMTU) { - m_adj(nmp, ETHER_ALIGN); - } + if (ifp->if_mtu <= ETHERMTU) { + m_adj(nmp, ETHER_ALIGN); + } - rx_buffer->m_head = nmp; - rx_buffer->buffer_addr = vtophys(mtod(nmp, vm_offset_t)); + rx_buffer->m_head = nmp; + rx_buffer->buffer_addr = vtophys(mtod(nmp, vm_offset_t)); - return (0); + return(0); } /********************************************************************* * * Allocate memory for rx_buffer structures. Since we use one * rx_buffer per received packet, the maximum number of rx_buffer's * that we'll need is equal to the number of receive descriptors * that we've allocated. * **********************************************************************/ static int em_allocate_receive_structures(struct adapter * adapter) { - int i; - struct em_rx_buffer *rx_buffer; + int i; + struct em_rx_buffer *rx_buffer; - if (!(adapter->rx_buffer_area = - (struct em_rx_buffer *) malloc(sizeof(struct em_rx_buffer) * - adapter->num_rx_desc, M_DEVBUF, - M_NOWAIT))) { - printf("em%d: Unable to allocate rx_buffer memory\n", adapter->unit); - return (ENOMEM); - } + if (!(adapter->rx_buffer_area = + (struct em_rx_buffer *) malloc(sizeof(struct em_rx_buffer) * + adapter->num_rx_desc, M_DEVBUF, + M_NOWAIT))) { + printf("em%d: Unable to allocate rx_buffer memory\n", + adapter->unit); + return(ENOMEM); + } - bzero(adapter->rx_buffer_area, - sizeof(struct em_rx_buffer) * adapter->num_rx_desc); + bzero(adapter->rx_buffer_area, + sizeof(struct em_rx_buffer) * adapter->num_rx_desc); - for (i = 0, rx_buffer = adapter->rx_buffer_area; - i < adapter->num_rx_desc; i++, rx_buffer++) { + for (i = 0, rx_buffer = adapter->rx_buffer_area; + i < adapter->num_rx_desc; i++, rx_buffer++) { - if (em_get_buf(rx_buffer, adapter, NULL) == ENOBUFS) { - rx_buffer->m_head = NULL; - return (ENOBUFS); - } - } + if (em_get_buf(rx_buffer, adapter, NULL) == ENOBUFS) { + rx_buffer->m_head = NULL; + return(ENOBUFS); + } + } - return (0); + return(0); } /********************************************************************* * * Allocate and initialize receive structures. * **********************************************************************/ static int em_setup_receive_structures(struct adapter * adapter) { - struct em_rx_buffer *rx_buffer; - struct em_rx_desc *rx_desc; - int i; + struct em_rx_buffer *rx_buffer; + struct em_rx_desc *rx_desc; + int i; - if(em_allocate_receive_structures(adapter)) - return ENOMEM; + if (em_allocate_receive_structures(adapter)) + return ENOMEM; - STAILQ_INIT(&adapter->rx_buffer_list); + STAILQ_INIT(&adapter->rx_buffer_list); - adapter->first_rx_desc = - (struct em_rx_desc *) adapter->rx_desc_base; - adapter->last_rx_desc = - adapter->first_rx_desc + (adapter->num_rx_desc - 1); + adapter->first_rx_desc = + (struct em_rx_desc *) adapter->rx_desc_base; + adapter->last_rx_desc = + adapter->first_rx_desc + (adapter->num_rx_desc - 1); - rx_buffer = (struct em_rx_buffer *) adapter->rx_buffer_area; + rx_buffer = (struct em_rx_buffer *) adapter->rx_buffer_area; - bzero((void *) adapter->first_rx_desc, - (sizeof(struct em_rx_desc)) * adapter->num_rx_desc); + bzero((void *) adapter->first_rx_desc, + (sizeof(struct em_rx_desc)) * adapter->num_rx_desc); - /* Build a linked list of rx_buffer's */ - for (i = 0, rx_desc = adapter->first_rx_desc; - i < adapter->num_rx_desc; - i++, rx_buffer++, rx_desc++) { - if (rx_buffer->m_head == NULL) - printf("em%d: Receive buffer memory not allocated", adapter->unit); - else { - rx_desc->buffer_addr = rx_buffer->buffer_addr; - STAILQ_INSERT_TAIL(&adapter->rx_buffer_list, rx_buffer, em_rx_entry); - } - } + /* Build a linked list of rx_buffer's */ + for (i = 0, rx_desc = adapter->first_rx_desc; + i < adapter->num_rx_desc; + i++, rx_buffer++, rx_desc++) { + if (rx_buffer->m_head == NULL) + printf("em%d: Receive buffer memory not allocated", + adapter->unit); + else { + rx_desc->buffer_addr = rx_buffer->buffer_addr; + STAILQ_INSERT_TAIL(&adapter->rx_buffer_list, + rx_buffer, em_rx_entry); + } + } - /* Setup our descriptor pointers */ - adapter->next_rx_desc_to_check = adapter->first_rx_desc; + /* Setup our descriptor pointers */ + adapter->next_rx_desc_to_check = adapter->first_rx_desc; - return(0); + return(0); } /********************************************************************* * * Enable receive unit. * **********************************************************************/ static void em_initialize_receive_unit(struct adapter * adapter) { - u_int32_t reg_rctl; - u_int32_t reg_rxcsum; - struct ifnet *ifp; - - ifp = &adapter->interface_data.ac_if; + u_int32_t reg_rctl; + u_int32_t reg_rxcsum; + struct ifnet *ifp; - /* Make sure receives are disabled while setting up the descriptor ring */ - E1000_WRITE_REG(&adapter->shared, RCTL, 0); + ifp = &adapter->interface_data.ac_if; - /* Set the Receive Delay Timer Register */ - E1000_WRITE_REG(&adapter->shared, RDTR, adapter->rx_int_delay | E1000_RDT_FPDB); + /* Make sure receives are disabled while setting up the descriptor ring */ + E1000_WRITE_REG(&adapter->hw, RCTL, 0); - /* Setup the Base and Length of the Rx Descriptor Ring */ - E1000_WRITE_REG(&adapter->shared, RDBAL, vtophys((vm_offset_t) adapter->rx_desc_base)); - E1000_WRITE_REG(&adapter->shared, RDBAH, 0); - E1000_WRITE_REG(&adapter->shared, RDLEN, adapter->num_rx_desc * - sizeof(struct em_rx_desc)); + /* Set the Receive Delay Timer Register */ + E1000_WRITE_REG(&adapter->hw, RDTR, + adapter->rx_int_delay | E1000_RDT_FPDB); - /* Setup the HW Rx Head and Tail Descriptor Pointers */ - E1000_WRITE_REG(&adapter->shared, RDH, 0); - E1000_WRITE_REG(&adapter->shared, RDT, - (((uintptr_t) adapter->last_rx_desc - - (uintptr_t) adapter->first_rx_desc) >> 4)); - - /* Setup the Receive Control Register */ - reg_rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_LBM_NO | - E1000_RCTL_RDMTS_HALF | - (adapter->shared.mc_filter_type << E1000_RCTL_MO_SHIFT); + /* Setup the Base and Length of the Rx Descriptor Ring */ + E1000_WRITE_REG(&adapter->hw, RDBAL, + vtophys((vm_offset_t) adapter->rx_desc_base)); + E1000_WRITE_REG(&adapter->hw, RDBAH, 0); + E1000_WRITE_REG(&adapter->hw, RDLEN, adapter->num_rx_desc * + sizeof(struct em_rx_desc)); - if (adapter->shared.tbi_compatibility_on == TRUE) - reg_rctl |= E1000_RCTL_SBP; + /* Setup the HW Rx Head and Tail Descriptor Pointers */ + E1000_WRITE_REG(&adapter->hw, RDH, 0); + E1000_WRITE_REG(&adapter->hw, RDT, + (((uintptr_t) adapter->last_rx_desc - + (uintptr_t) adapter->first_rx_desc) >> 4)); + /* Setup the Receive Control Register */ + reg_rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_LBM_NO | + E1000_RCTL_RDMTS_HALF | + (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT); - switch (adapter->rx_buffer_len) { - case EM_RXBUFFER_2048: - reg_rctl |= E1000_RCTL_SZ_2048 | E1000_RCTL_LPE; - break; - case EM_RXBUFFER_4096: - reg_rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX | E1000_RCTL_LPE; - break; - case EM_RXBUFFER_8192: - reg_rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX | E1000_RCTL_LPE; - break; - case EM_RXBUFFER_16384: - reg_rctl |= E1000_RCTL_SZ_16384 | E1000_RCTL_BSEX | E1000_RCTL_LPE; - break; - default: - reg_rctl |= E1000_RCTL_SZ_2048; - } + if (adapter->hw.tbi_compatibility_on == TRUE) + reg_rctl |= E1000_RCTL_SBP; - /* Enable 82543 Receive Checksum Offload for TCP and UDP */ - if((adapter->shared.mac_type >= em_82543) && (ifp->if_capenable & IFCAP_RXCSUM)) { - reg_rxcsum = E1000_READ_REG(&adapter->shared, RXCSUM); - reg_rxcsum |= (E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); - E1000_WRITE_REG(&adapter->shared, RXCSUM, reg_rxcsum); - } - /* Enable Receives */ - E1000_WRITE_REG(&adapter->shared, RCTL, reg_rctl); + switch (adapter->rx_buffer_len) { + case EM_RXBUFFER_2048: + reg_rctl |= E1000_RCTL_SZ_2048 | E1000_RCTL_LPE; + break; + case EM_RXBUFFER_4096: + reg_rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX | E1000_RCTL_LPE; + break; + case EM_RXBUFFER_8192: + reg_rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX | E1000_RCTL_LPE; + break; + case EM_RXBUFFER_16384: + reg_rctl |= E1000_RCTL_SZ_16384 | E1000_RCTL_BSEX | E1000_RCTL_LPE; + break; + default: + reg_rctl |= E1000_RCTL_SZ_2048; + } - return; + /* Enable 82543 Receive Checksum Offload for TCP and UDP */ + if ((adapter->hw.mac_type >= em_82543) && + (ifp->if_capenable & IFCAP_RXCSUM)) { + reg_rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM); + reg_rxcsum |= (E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); + E1000_WRITE_REG(&adapter->hw, RXCSUM, reg_rxcsum); + } + + /* Enable Receives */ + E1000_WRITE_REG(&adapter->hw, RCTL, reg_rctl); + + return; } /********************************************************************* * * Free receive related data structures. * **********************************************************************/ static void em_free_receive_structures(struct adapter * adapter) { - struct em_rx_buffer *rx_buffer; - int i; + struct em_rx_buffer *rx_buffer; + int i; - INIT_DEBUGOUT("free_receive_structures: begin"); + INIT_DEBUGOUT("free_receive_structures: begin"); - if (adapter->rx_buffer_area != NULL) { - rx_buffer = adapter->rx_buffer_area; - for (i = 0; i < adapter->num_rx_desc; i++, rx_buffer++) { - if (rx_buffer->m_head != NULL) - m_freem(rx_buffer->m_head); - rx_buffer->m_head = NULL; - } - } - if (adapter->rx_buffer_area != NULL) { - free(adapter->rx_buffer_area, M_DEVBUF); - adapter->rx_buffer_area = NULL; - } - return; + if (adapter->rx_buffer_area != NULL) { + rx_buffer = adapter->rx_buffer_area; + for (i = 0; i < adapter->num_rx_desc; i++, rx_buffer++) { + if (rx_buffer->m_head != NULL) + m_freem(rx_buffer->m_head); + rx_buffer->m_head = NULL; + } + } + if (adapter->rx_buffer_area != NULL) { + free(adapter->rx_buffer_area, M_DEVBUF); + adapter->rx_buffer_area = NULL; + } + return; } /********************************************************************* * * This routine executes in interrupt context. It replenishes * the mbufs in the descriptor and sends data which has been * dma'ed into host memory to upper layer. * *********************************************************************/ static void em_process_receive_interrupts(struct adapter * adapter) { - struct mbuf *mp; - struct ifnet *ifp; - struct ether_header *eh; - u_int16_t len; - u_int8_t last_byte; - u_int8_t accept_frame = 0; - u_int8_t eop = 0; - u_int32_t pkt_len = 0; + struct mbuf *mp; + struct ifnet *ifp; + struct ether_header *eh; + u_int16_t len; + u_int8_t last_byte; + u_int8_t accept_frame = 0; + u_int8_t eop = 0; + u_int32_t pkt_len = 0; - /* Pointer to the receive descriptor being examined. */ - struct em_rx_desc *current_desc; - struct em_rx_desc *last_desc_processed; - struct em_rx_buffer *rx_buffer; + /* Pointer to the receive descriptor being examined. */ + struct em_rx_desc *current_desc; + struct em_rx_desc *last_desc_processed; + struct em_rx_buffer *rx_buffer; - ifp = &adapter->interface_data.ac_if; - current_desc = adapter->next_rx_desc_to_check; + ifp = &adapter->interface_data.ac_if; + current_desc = adapter->next_rx_desc_to_check; - if (!((current_desc->status) & E1000_RXD_STAT_DD)) { + if (!((current_desc->status) & E1000_RXD_STAT_DD)) { #ifdef DBG_STATS - adapter->no_pkts_avail++; + adapter->no_pkts_avail++; #endif - return; - } - - while (current_desc->status & E1000_RXD_STAT_DD) { + return; + } - /* Get a pointer to the actual receive buffer */ - rx_buffer = STAILQ_FIRST(&adapter->rx_buffer_list); + while (current_desc->status & E1000_RXD_STAT_DD) { - if(rx_buffer == NULL) { - printf("em%d: Found null rx_buffer\n", adapter->unit); - return; - } + /* Get a pointer to the actual receive buffer */ + rx_buffer = STAILQ_FIRST(&adapter->rx_buffer_list); - mp = rx_buffer->m_head; - accept_frame = 1; + if (rx_buffer == NULL) { + printf("em%d: Found null rx_buffer\n", adapter->unit); + return; + } - if (current_desc->status & E1000_RXD_STAT_EOP) { - eop = 1; - len = current_desc->length - ETHER_CRC_LEN; - } - else { - eop = 0; - len = current_desc->length; - } + mp = rx_buffer->m_head; + accept_frame = 1; - if(current_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK) { - - /* Compute packet length for tbi_accept macro */ - pkt_len = current_desc->length; - if (adapter->fmp != NULL) { - pkt_len += adapter->fmp->m_pkthdr.len; - } + if (current_desc->status & E1000_RXD_STAT_EOP) { + eop = 1; + len = current_desc->length - ETHER_CRC_LEN; + } else { + eop = 0; + len = current_desc->length; + } - last_byte = *(mtod(rx_buffer->m_head,caddr_t) + current_desc->length - 1); + if (current_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK) { - if (TBI_ACCEPT(&adapter->shared, current_desc->status, - current_desc->errors, - pkt_len, last_byte)) { - pkt_len = em_tbi_adjust_stats(&adapter->shared, &adapter->stats, - pkt_len, adapter->shared.mac_addr); - len--; - } else { - accept_frame = 0; - } - } + /* Compute packet length for tbi_accept macro */ + pkt_len = current_desc->length; + if (adapter->fmp != NULL) { + pkt_len += adapter->fmp->m_pkthdr.len; + } - if (accept_frame) { + last_byte = *(mtod(rx_buffer->m_head,caddr_t) + + current_desc->length - 1); - if (em_get_buf(rx_buffer, adapter, NULL) == ENOBUFS) { - adapter->dropped_pkts++; - em_get_buf(rx_buffer, adapter, mp); - if(adapter->fmp != NULL) m_freem(adapter->fmp); - adapter->fmp = NULL; - adapter->lmp = NULL; - break; - } + if (TBI_ACCEPT(&adapter->hw, current_desc->status, + current_desc->errors, + pkt_len, last_byte)) { + em_tbi_adjust_stats(&adapter->hw, + &adapter->stats, + pkt_len, + adapter->hw.mac_addr); + len--; + } else { + accept_frame = 0; + } + } - /* Assign correct length to the current fragment */ - mp->m_len = len; + if (accept_frame) { - if(adapter->fmp == NULL) { - mp->m_pkthdr.len = len; - adapter->fmp = mp; /* Store the first mbuf */ - adapter->lmp = mp; - } - else { - /* Chain mbuf's together */ - mp->m_flags &= ~M_PKTHDR; - adapter->lmp->m_next = mp; - adapter->lmp = adapter->lmp->m_next; - adapter->fmp->m_pkthdr.len += len; - } + if (em_get_buf(rx_buffer, adapter, NULL) == ENOBUFS) { + adapter->dropped_pkts++; + em_get_buf(rx_buffer, adapter, mp); + if (adapter->fmp != NULL) m_freem(adapter->fmp); + adapter->fmp = NULL; + adapter->lmp = NULL; + break; + } - if (eop) { - adapter->fmp->m_pkthdr.rcvif = ifp; + /* Assign correct length to the current fragment */ + mp->m_len = len; - eh = mtod(adapter->fmp, struct ether_header *); + if (adapter->fmp == NULL) { + mp->m_pkthdr.len = len; + adapter->fmp = mp; /* Store the first mbuf */ + adapter->lmp = mp; + } else { + /* Chain mbuf's together */ + mp->m_flags &= ~M_PKTHDR; + adapter->lmp->m_next = mp; + adapter->lmp = adapter->lmp->m_next; + adapter->fmp->m_pkthdr.len += len; + } - /* Remove ethernet header from mbuf */ - m_adj(adapter->fmp, sizeof(struct ether_header)); - em_receive_checksum(adapter, current_desc, adapter->fmp); - ether_input(ifp, eh, adapter->fmp); - - adapter->fmp = NULL; - adapter->lmp = NULL; - } - } else { - adapter->dropped_pkts++; - em_get_buf(rx_buffer, adapter, mp); - if(adapter->fmp != NULL) m_freem(adapter->fmp); - adapter->fmp = NULL; - adapter->lmp = NULL; - } - - /* Zero out the receive descriptors status */ - current_desc->status = 0; - - if (rx_buffer->m_head != NULL) { - current_desc->buffer_addr = rx_buffer->buffer_addr; - } + if (eop) { + adapter->fmp->m_pkthdr.rcvif = ifp; - /* Advance our pointers to the next descriptor (checking for wrap). */ - if (current_desc == adapter->last_rx_desc) - adapter->next_rx_desc_to_check = adapter->first_rx_desc; - else - ((adapter)->next_rx_desc_to_check)++; + eh = mtod(adapter->fmp, struct ether_header *); - last_desc_processed = current_desc; - current_desc = adapter->next_rx_desc_to_check; - /* - * Put the buffer that we just indicated back at the end of our list - */ - STAILQ_REMOVE_HEAD(&adapter->rx_buffer_list, em_rx_entry); - STAILQ_INSERT_TAIL(&adapter->rx_buffer_list, rx_buffer, em_rx_entry); + /* Remove ethernet header from mbuf */ + m_adj(adapter->fmp, sizeof(struct ether_header)); + em_receive_checksum(adapter, current_desc, + adapter->fmp); + if (current_desc->status & E1000_RXD_STAT_VP) + VLAN_INPUT_TAG(eh, adapter->fmp, + current_desc->special); + else + ether_input(ifp, eh, adapter->fmp); - /* Advance the E1000's Receive Queue #0 "Tail Pointer". */ - E1000_WRITE_REG(&adapter->shared, RDT, (((u_int32_t) last_desc_processed - - (u_int32_t) adapter->first_rx_desc) >> 4)); - } - return; + adapter->fmp = NULL; + adapter->lmp = NULL; + } + } else { + adapter->dropped_pkts++; + em_get_buf(rx_buffer, adapter, mp); + if (adapter->fmp != NULL) m_freem(adapter->fmp); + adapter->fmp = NULL; + adapter->lmp = NULL; + } + + /* Zero out the receive descriptors status */ + current_desc->status = 0; + + if (rx_buffer->m_head != NULL) { + current_desc->buffer_addr = rx_buffer->buffer_addr; + } + + /* Advance our pointers to the next descriptor (checking for wrap). */ + if (current_desc == adapter->last_rx_desc) + adapter->next_rx_desc_to_check = adapter->first_rx_desc; + else + ((adapter)->next_rx_desc_to_check)++; + + last_desc_processed = current_desc; + current_desc = adapter->next_rx_desc_to_check; + /* + * Put the buffer that we just indicated back at the end of our list + */ + STAILQ_REMOVE_HEAD(&adapter->rx_buffer_list, em_rx_entry); + STAILQ_INSERT_TAIL(&adapter->rx_buffer_list, + rx_buffer, em_rx_entry); + + /* Advance the E1000's Receive Queue #0 "Tail Pointer". */ + E1000_WRITE_REG(&adapter->hw, RDT, + (((u_long) last_desc_processed - + (u_long) adapter->first_rx_desc) >> 4)); + } + return; } /********************************************************************* * * Verify that the hardware indicated that the checksum is valid. * Inform the stack about the status of checksum so that stack * doesn't spend time verifying the checksum. * *********************************************************************/ static void em_receive_checksum(struct adapter *adapter, - struct em_rx_desc *rx_desc, - struct mbuf *mp) + struct em_rx_desc *rx_desc, + struct mbuf *mp) { - /* 82543 or newer only */ - if((adapter->shared.mac_type < em_82543) || - /* Ignore Checksum bit is set */ - (rx_desc->status & E1000_RXD_STAT_IXSM)) { - mp->m_pkthdr.csum_flags = 0; - return; - } + /* 82543 or newer only */ + if ((adapter->hw.mac_type < em_82543) || + /* Ignore Checksum bit is set */ + (rx_desc->status & E1000_RXD_STAT_IXSM)) { + mp->m_pkthdr.csum_flags = 0; + return; + } - if (rx_desc->status & E1000_RXD_STAT_IPCS) { - /* Did it pass? */ - if (!(rx_desc->errors & E1000_RXD_ERR_IPE)) { - /* IP Checksum Good */ - mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; - mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; + if (rx_desc->status & E1000_RXD_STAT_IPCS) { + /* Did it pass? */ + if (!(rx_desc->errors & E1000_RXD_ERR_IPE)) { + /* IP Checksum Good */ + mp->m_pkthdr.csum_flags = CSUM_IP_CHECKED; + mp->m_pkthdr.csum_flags |= CSUM_IP_VALID; - } - else { - mp->m_pkthdr.csum_flags = 0; - } - } + } else { + mp->m_pkthdr.csum_flags = 0; + } + } - if (rx_desc->status & E1000_RXD_STAT_TCPCS) { - /* Did it pass? */ - if (!(rx_desc->errors & E1000_RXD_ERR_TCPE)) { - mp->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); - mp->m_pkthdr.csum_data = htons(0xffff); - } - } + if (rx_desc->status & E1000_RXD_STAT_TCPCS) { + /* Did it pass? */ + if (!(rx_desc->errors & E1000_RXD_ERR_TCPE)) { + mp->m_pkthdr.csum_flags |= + (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); + mp->m_pkthdr.csum_data = htons(0xffff); + } + } - return; + return; } +static void em_enable_vlans(struct adapter *adapter) +{ + uint32_t ctrl; + + E1000_WRITE_REG(&adapter->hw, VET, QTAG_TYPE); + + ctrl = E1000_READ_REG(&adapter->hw, CTRL); + ctrl |= E1000_CTRL_VME; + E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); + + return; +} + static void em_enable_intr(struct adapter * adapter) { - E1000_WRITE_REG(&adapter->shared, IMS, (IMS_ENABLE_MASK)); - return; + E1000_WRITE_REG(&adapter->hw, IMS, (IMS_ENABLE_MASK)); + return; } static void -em_disable_intr(struct adapter * adapter) +em_disable_intr(struct adapter *adapter) { - E1000_WRITE_REG(&adapter->shared, IMC, (0xffffffff & ~E1000_IMC_RXSEQ)); - return; + E1000_WRITE_REG(&adapter->hw, IMC, + (0xffffffff & ~E1000_IMC_RXSEQ)); + return; } -void em_write_pci_cfg(struct em_shared_adapter *adapter, - uint32_t reg, - uint16_t * value) +void em_write_pci_cfg(struct em_hw *adapter, + uint32_t reg, + uint16_t *value) { - pci_write_config(((struct em_osdep *)adapter->back)->dev, reg, *value, 2); + pci_write_config(((struct em_osdep *)adapter->back)->dev, reg, + *value, 2); } /********************************************************************** * * Update the board statistics counters. * **********************************************************************/ static void -em_update_stats_counters(struct adapter * adapter) +em_update_stats_counters(struct adapter *adapter) { - struct ifnet *ifp; + struct ifnet *ifp; - adapter->stats.crcerrs += E1000_READ_REG(&adapter->shared, CRCERRS); - adapter->stats.symerrs += E1000_READ_REG(&adapter->shared, SYMERRS); - adapter->stats.mpc += E1000_READ_REG(&adapter->shared, MPC); - adapter->stats.scc += E1000_READ_REG(&adapter->shared, SCC); - adapter->stats.ecol += E1000_READ_REG(&adapter->shared, ECOL); - adapter->stats.mcc += E1000_READ_REG(&adapter->shared, MCC); - adapter->stats.latecol += E1000_READ_REG(&adapter->shared, LATECOL); - adapter->stats.colc += E1000_READ_REG(&adapter->shared, COLC); - adapter->stats.dc += E1000_READ_REG(&adapter->shared, DC); - adapter->stats.sec += E1000_READ_REG(&adapter->shared, SEC); - adapter->stats.rlec += E1000_READ_REG(&adapter->shared, RLEC); - adapter->stats.xonrxc += E1000_READ_REG(&adapter->shared, XONRXC); - adapter->stats.xontxc += E1000_READ_REG(&adapter->shared, XONTXC); - adapter->stats.xoffrxc += E1000_READ_REG(&adapter->shared, XOFFRXC); - adapter->stats.xofftxc += E1000_READ_REG(&adapter->shared, XOFFTXC); - adapter->stats.fcruc += E1000_READ_REG(&adapter->shared, FCRUC); - adapter->stats.prc64 += E1000_READ_REG(&adapter->shared, PRC64); - adapter->stats.prc127 += E1000_READ_REG(&adapter->shared, PRC127); - adapter->stats.prc255 += E1000_READ_REG(&adapter->shared, PRC255); - adapter->stats.prc511 += E1000_READ_REG(&adapter->shared, PRC511); - adapter->stats.prc1023 += E1000_READ_REG(&adapter->shared, PRC1023); - adapter->stats.prc1522 += E1000_READ_REG(&adapter->shared, PRC1522); - adapter->stats.gprc += E1000_READ_REG(&adapter->shared, GPRC); - adapter->stats.bprc += E1000_READ_REG(&adapter->shared, BPRC); - adapter->stats.mprc += E1000_READ_REG(&adapter->shared, MPRC); - adapter->stats.gptc += E1000_READ_REG(&adapter->shared, GPTC); + adapter->stats.crcerrs += E1000_READ_REG(&adapter->hw, CRCERRS); + adapter->stats.symerrs += E1000_READ_REG(&adapter->hw, SYMERRS); + adapter->stats.mpc += E1000_READ_REG(&adapter->hw, MPC); + adapter->stats.scc += E1000_READ_REG(&adapter->hw, SCC); + adapter->stats.ecol += E1000_READ_REG(&adapter->hw, ECOL); + adapter->stats.mcc += E1000_READ_REG(&adapter->hw, MCC); + adapter->stats.latecol += E1000_READ_REG(&adapter->hw, LATECOL); + adapter->stats.colc += E1000_READ_REG(&adapter->hw, COLC); + adapter->stats.dc += E1000_READ_REG(&adapter->hw, DC); + adapter->stats.sec += E1000_READ_REG(&adapter->hw, SEC); + adapter->stats.rlec += E1000_READ_REG(&adapter->hw, RLEC); + adapter->stats.xonrxc += E1000_READ_REG(&adapter->hw, XONRXC); + adapter->stats.xontxc += E1000_READ_REG(&adapter->hw, XONTXC); + adapter->stats.xoffrxc += E1000_READ_REG(&adapter->hw, XOFFRXC); + adapter->stats.xofftxc += E1000_READ_REG(&adapter->hw, XOFFTXC); + adapter->stats.fcruc += E1000_READ_REG(&adapter->hw, FCRUC); + adapter->stats.prc64 += E1000_READ_REG(&adapter->hw, PRC64); + adapter->stats.prc127 += E1000_READ_REG(&adapter->hw, PRC127); + adapter->stats.prc255 += E1000_READ_REG(&adapter->hw, PRC255); + adapter->stats.prc511 += E1000_READ_REG(&adapter->hw, PRC511); + adapter->stats.prc1023 += E1000_READ_REG(&adapter->hw, PRC1023); + adapter->stats.prc1522 += E1000_READ_REG(&adapter->hw, PRC1522); + adapter->stats.gprc += E1000_READ_REG(&adapter->hw, GPRC); + adapter->stats.bprc += E1000_READ_REG(&adapter->hw, BPRC); + adapter->stats.mprc += E1000_READ_REG(&adapter->hw, MPRC); + adapter->stats.gptc += E1000_READ_REG(&adapter->hw, GPTC); - /* For the 64-bit byte counters the low dword must be read first. */ - /* Both registers clear on the read of the high dword */ + /* For the 64-bit byte counters the low dword must be read first. */ + /* Both registers clear on the read of the high dword */ - adapter->stats.gorcl += E1000_READ_REG(&adapter->shared, GORCL); - adapter->stats.gorch += E1000_READ_REG(&adapter->shared, GORCH); - adapter->stats.gotcl += E1000_READ_REG(&adapter->shared, GOTCL); - adapter->stats.gotch += E1000_READ_REG(&adapter->shared, GOTCH); + adapter->stats.gorcl += E1000_READ_REG(&adapter->hw, GORCL); + adapter->stats.gorch += E1000_READ_REG(&adapter->hw, GORCH); + adapter->stats.gotcl += E1000_READ_REG(&adapter->hw, GOTCL); + adapter->stats.gotch += E1000_READ_REG(&adapter->hw, GOTCH); - adapter->stats.rnbc += E1000_READ_REG(&adapter->shared, RNBC); - adapter->stats.ruc += E1000_READ_REG(&adapter->shared, RUC); - adapter->stats.rfc += E1000_READ_REG(&adapter->shared, RFC); - adapter->stats.roc += E1000_READ_REG(&adapter->shared, ROC); - adapter->stats.rjc += E1000_READ_REG(&adapter->shared, RJC); + adapter->stats.rnbc += E1000_READ_REG(&adapter->hw, RNBC); + adapter->stats.ruc += E1000_READ_REG(&adapter->hw, RUC); + adapter->stats.rfc += E1000_READ_REG(&adapter->hw, RFC); + adapter->stats.roc += E1000_READ_REG(&adapter->hw, ROC); + adapter->stats.rjc += E1000_READ_REG(&adapter->hw, RJC); - adapter->stats.torl += E1000_READ_REG(&adapter->shared, TORL); - adapter->stats.torh += E1000_READ_REG(&adapter->shared, TORH); - adapter->stats.totl += E1000_READ_REG(&adapter->shared, TOTL); - adapter->stats.toth += E1000_READ_REG(&adapter->shared, TOTH); + adapter->stats.torl += E1000_READ_REG(&adapter->hw, TORL); + adapter->stats.torh += E1000_READ_REG(&adapter->hw, TORH); + adapter->stats.totl += E1000_READ_REG(&adapter->hw, TOTL); + adapter->stats.toth += E1000_READ_REG(&adapter->hw, TOTH); - adapter->stats.tpr += E1000_READ_REG(&adapter->shared, TPR); - adapter->stats.tpt += E1000_READ_REG(&adapter->shared, TPT); - adapter->stats.ptc64 += E1000_READ_REG(&adapter->shared, PTC64); - adapter->stats.ptc127 += E1000_READ_REG(&adapter->shared, PTC127); - adapter->stats.ptc255 += E1000_READ_REG(&adapter->shared, PTC255); - adapter->stats.ptc511 += E1000_READ_REG(&adapter->shared, PTC511); - adapter->stats.ptc1023 += E1000_READ_REG(&adapter->shared, PTC1023); - adapter->stats.ptc1522 += E1000_READ_REG(&adapter->shared, PTC1522); - adapter->stats.mptc += E1000_READ_REG(&adapter->shared, MPTC); - adapter->stats.bptc += E1000_READ_REG(&adapter->shared, BPTC); + adapter->stats.tpr += E1000_READ_REG(&adapter->hw, TPR); + adapter->stats.tpt += E1000_READ_REG(&adapter->hw, TPT); + adapter->stats.ptc64 += E1000_READ_REG(&adapter->hw, PTC64); + adapter->stats.ptc127 += E1000_READ_REG(&adapter->hw, PTC127); + adapter->stats.ptc255 += E1000_READ_REG(&adapter->hw, PTC255); + adapter->stats.ptc511 += E1000_READ_REG(&adapter->hw, PTC511); + adapter->stats.ptc1023 += E1000_READ_REG(&adapter->hw, PTC1023); + adapter->stats.ptc1522 += E1000_READ_REG(&adapter->hw, PTC1522); + adapter->stats.mptc += E1000_READ_REG(&adapter->hw, MPTC); + adapter->stats.bptc += E1000_READ_REG(&adapter->hw, BPTC); - if (adapter->shared.mac_type >= em_82543) { - adapter->stats.algnerrc += E1000_READ_REG(&adapter->shared, ALGNERRC); - adapter->stats.rxerrc += E1000_READ_REG(&adapter->shared, RXERRC); - adapter->stats.tncrs += E1000_READ_REG(&adapter->shared, TNCRS); - adapter->stats.cexterr += E1000_READ_REG(&adapter->shared, CEXTERR); - adapter->stats.tsctc += E1000_READ_REG(&adapter->shared, TSCTC); - adapter->stats.tsctfc += E1000_READ_REG(&adapter->shared, TSCTFC); - } - ifp = &adapter->interface_data.ac_if; + if (adapter->hw.mac_type >= em_82543) { + adapter->stats.algnerrc += + E1000_READ_REG(&adapter->hw, ALGNERRC); + adapter->stats.rxerrc += + E1000_READ_REG(&adapter->hw, RXERRC); + adapter->stats.tncrs += + E1000_READ_REG(&adapter->hw, TNCRS); + adapter->stats.cexterr += + E1000_READ_REG(&adapter->hw, CEXTERR); + adapter->stats.tsctc += + E1000_READ_REG(&adapter->hw, TSCTC); + adapter->stats.tsctfc += + E1000_READ_REG(&adapter->hw, TSCTFC); + } + ifp = &adapter->interface_data.ac_if; - /* Fill out the OS statistics structure */ - ifp->if_ipackets = adapter->stats.gprc; - ifp->if_opackets = adapter->stats.gptc; - ifp->if_ibytes = adapter->stats.gorcl; - ifp->if_obytes = adapter->stats.gotcl; - ifp->if_imcasts = adapter->stats.mprc; - ifp->if_collisions = adapter->stats.colc; + /* Fill out the OS statistics structure */ + ifp->if_ipackets = adapter->stats.gprc; + ifp->if_opackets = adapter->stats.gptc; + ifp->if_ibytes = adapter->stats.gorcl; + ifp->if_obytes = adapter->stats.gotcl; + ifp->if_imcasts = adapter->stats.mprc; + ifp->if_collisions = adapter->stats.colc; - /* Rx Errors */ - ifp->if_ierrors = - adapter->dropped_pkts + - adapter->stats.rxerrc + - adapter->stats.crcerrs + - adapter->stats.algnerrc + - adapter->stats.rlec + adapter->stats.rnbc + - adapter->stats.mpc + adapter->stats.cexterr; + /* Rx Errors */ + ifp->if_ierrors = + adapter->dropped_pkts + + adapter->stats.rxerrc + + adapter->stats.crcerrs + + adapter->stats.algnerrc + + adapter->stats.rlec + adapter->stats.rnbc + + adapter->stats.mpc + adapter->stats.cexterr; - /* Tx Errors */ - ifp->if_oerrors = adapter->stats.ecol + adapter->stats.latecol; + /* Tx Errors */ + ifp->if_oerrors = adapter->stats.ecol + adapter->stats.latecol; } /********************************************************************** * * This routine is called only when em_display_debug_stats is enabled. * This routine provides a way to take a look at important statistics * maintained by the driver and hardware. * **********************************************************************/ static void -em_print_hw_stats(struct adapter * adapter) +em_print_hw_stats(struct adapter *adapter) { - int unit = adapter->unit; + int unit = adapter->unit; #ifdef DBG_STATS - printf("em%d: Packets not Avail = %ld\n", unit, adapter->no_pkts_avail); - printf("em%d: clean_tx_interrupts = %ld\n", unit, adapter->clean_tx_interrupts); + printf("em%d: Packets not Avail = %ld\n", unit, + adapter->no_pkts_avail); + printf("em%d: CleanTxInterrupts = %ld\n", unit, + adapter->clean_tx_interrupts); #endif - - printf("em%d: Tx Descriptors not Avail = %ld\n", unit, adapter->no_tx_desc_avail); - printf("em%d: Tx Buffer not avail1 = %ld\n", unit, adapter->no_tx_buffer_avail1); - printf("em%d: Tx Buffer not avail2 = %ld\n", unit, adapter->no_tx_buffer_avail2); - printf("em%d: Std Mbuf Failed = %ld\n",unit, adapter->mbuf_alloc_failed); - printf("em%d: Std Cluster Failed = %ld\n",unit, adapter->mbuf_cluster_failed); - printf("em%d: Xmit Pullup = %ld\n",unit, adapter->xmit_pullup); - printf("em%d: Symbol errors = %lld\n", unit, adapter->stats.symerrs); - printf("em%d: Sequence errors = %lld\n", unit, adapter->stats.sec); - printf("em%d: Defer count = %lld\n", unit, adapter->stats.dc); + printf("em%d: Tx Descriptors not Avail = %ld\n", unit, + adapter->no_tx_desc_avail); + printf("em%d: Tx Buffer not avail1 = %ld\n", unit, + adapter->no_tx_buffer_avail1); + printf("em%d: Tx Buffer not avail2 = %ld\n", unit, + adapter->no_tx_buffer_avail2); + printf("em%d: Std Mbuf Failed = %ld\n",unit, + adapter->mbuf_alloc_failed); + printf("em%d: Std Cluster Failed = %ld\n",unit, + adapter->mbuf_cluster_failed); - printf("em%d: Missed Packets = %lld\n", unit, adapter->stats.mpc); - printf("em%d: Receive No Buffers = %lld\n", unit, adapter->stats.rnbc); - printf("em%d: Receive length errors = %lld\n", unit, adapter->stats.rlec); - printf("em%d: Receive errors = %lld\n", unit, adapter->stats.rxerrc); - printf("em%d: Crc errors = %lld\n", unit, adapter->stats.crcerrs); - printf("em%d: Alignment errors = %lld\n", unit, adapter->stats.algnerrc); - printf("em%d: Carrier extension errors = %lld\n", unit, adapter->stats.cexterr); - printf("em%d: Driver dropped packets = %ld\n", unit, adapter->dropped_pkts); + printf("em%d: Symbol errors = %lld\n", unit, + (long long)adapter->stats.symerrs); + printf("em%d: Sequence errors = %lld\n", unit, + (long long)adapter->stats.sec); + printf("em%d: Defer count = %lld\n", unit, + (long long)adapter->stats.dc); - printf("em%d: XON Rcvd = %lld\n", unit, adapter->stats.xonrxc); - printf("em%d: XON Xmtd = %lld\n", unit, adapter->stats.xontxc); - printf("em%d: XOFF Rcvd = %lld\n", unit, adapter->stats.xoffrxc); - printf("em%d: XOFF Xmtd = %lld\n", unit, adapter->stats.xofftxc); + printf("em%d: Missed Packets = %lld\n", unit, + (long long)adapter->stats.mpc); + printf("em%d: Receive No Buffers = %lld\n", unit, + (long long)adapter->stats.rnbc); + printf("em%d: Receive length errors = %lld\n", unit, + (long long)adapter->stats.rlec); + printf("em%d: Receive errors = %lld\n", unit, + (long long)adapter->stats.rxerrc); + printf("em%d: Crc errors = %lld\n", unit, + (long long)adapter->stats.crcerrs); + printf("em%d: Alignment errors = %lld\n", unit, + (long long)adapter->stats.algnerrc); + printf("em%d: Carrier extension errors = %lld\n", unit, + (long long)adapter->stats.cexterr); + printf("em%d: Driver dropped packets = %ld\n", unit, + adapter->dropped_pkts); - printf("em%d: Good Packets Rcvd = %lld\n", unit, adapter->stats.gprc); - printf("em%d: Good Packets Xmtd = %lld\n", unit, adapter->stats.gptc); + printf("em%d: XON Rcvd = %lld\n", unit, + (long long)adapter->stats.xonrxc); + printf("em%d: XON Xmtd = %lld\n", unit, + (long long)adapter->stats.xontxc); + printf("em%d: XOFF Rcvd = %lld\n", unit, + (long long)adapter->stats.xoffrxc); + printf("em%d: XOFF Xmtd = %lld\n", unit, + (long long)adapter->stats.xofftxc); + + printf("em%d: Good Packets Rcvd = %lld\n", unit, + (long long)adapter->stats.gprc); + printf("em%d: Good Packets Xmtd = %lld\n", unit, + (long long)adapter->stats.gptc); + + return; } /********************************************************************** * * Examine each tx_buffer in the used queue. If the hardware is done * processing the packet then free associated resources. The * tx_buffer is put back on the free queue. * **********************************************************************/ static void em_clean_transmit_interrupts(struct adapter * adapter) { - struct em_tx_buffer *tx_buffer; - struct em_tx_desc *tx_desc; - int s; - struct ifnet *ifp; + struct em_tx_buffer *tx_buffer; + struct em_tx_desc *tx_desc; + int s; + struct ifnet *ifp; - s = splimp(); + s = splimp(); #ifdef DBG_STATS - adapter->clean_tx_interrupts++; + adapter->clean_tx_interrupts++; #endif - for (tx_buffer = STAILQ_FIRST(&adapter->used_tx_buffer_list); - tx_buffer; - tx_buffer = STAILQ_FIRST(&adapter->used_tx_buffer_list)) { + for (tx_buffer = STAILQ_FIRST(&adapter->used_tx_buffer_list); + tx_buffer; + tx_buffer = STAILQ_FIRST(&adapter->used_tx_buffer_list)) { - /* - * Get hold of the next descriptor that the em will report status - * back to (this will be the last descriptor of a given tx_buffer). We - * only want to free the tx_buffer (and it resources) if the driver is - * done with ALL of the descriptors. If the driver is done with the - * last one then it is done with all of them. - */ + /* + * Get hold of the next descriptor that the em will report status + * back to (this will be the last descriptor of a given tx_buffer). We + * only want to free the tx_buffer (and it resources) if the driver is + * done with ALL of the descriptors. If the driver is done with the + * last one then it is done with all of them. + */ - tx_desc = adapter->oldest_used_tx_desc + - (tx_buffer->num_tx_desc_used - 1); + tx_desc = adapter->oldest_used_tx_desc + + (tx_buffer->num_tx_desc_used - 1); - /* Check for wrap case */ - if (tx_desc > adapter->last_tx_desc) - tx_desc -= adapter->num_tx_desc; + /* Check for wrap case */ + if (tx_desc > adapter->last_tx_desc) + tx_desc -= adapter->num_tx_desc; - /* - * If the descriptor done bit is set free tx_buffer and associated - * resources - */ - if (tx_desc->upper.fields.status & - E1000_TXD_STAT_DD) { + /* + * If the descriptor done bit is set free tx_buffer and associated + * resources + */ + if (tx_desc->upper.fields.status & E1000_TXD_STAT_DD) { - STAILQ_REMOVE_HEAD(&adapter->used_tx_buffer_list, em_tx_entry); + STAILQ_REMOVE_HEAD(&adapter->used_tx_buffer_list, + em_tx_entry); - if ((tx_desc == adapter->last_tx_desc)) - adapter->oldest_used_tx_desc = - adapter->first_tx_desc; - else - adapter->oldest_used_tx_desc = (tx_desc + 1); + if ((tx_desc == adapter->last_tx_desc)) + adapter->oldest_used_tx_desc = + adapter->first_tx_desc; + else + adapter->oldest_used_tx_desc = (tx_desc + 1); - /* Make available the descriptors that were previously used */ - adapter->num_tx_desc_avail += - tx_buffer->num_tx_desc_used; + /* Make available the descriptors that were previously used */ + adapter->num_tx_desc_avail += + tx_buffer->num_tx_desc_used; - tx_buffer->num_tx_desc_used = 0; + tx_buffer->num_tx_desc_used = 0; - if (tx_buffer->m_head) { - m_freem(tx_buffer->m_head); - tx_buffer->m_head = NULL; - } - /* Return this "Software packet" back to the "free" list */ - STAILQ_INSERT_TAIL(&adapter->free_tx_buffer_list, tx_buffer, em_tx_entry); - } else { - /* - * Found a tx_buffer that the em is not done with then there is - * no reason to check the rest of the queue. - */ - break; - } - } /* end for each tx_buffer */ + if (tx_buffer->m_head) { + m_freem(tx_buffer->m_head); + tx_buffer->m_head = NULL; + } + /* Return this "Software packet" back to the "free" list */ + STAILQ_INSERT_TAIL(&adapter->free_tx_buffer_list, + tx_buffer, em_tx_entry); + } else { + /* + * Found a tx_buffer that the em is not done with then there is + * no reason to check the rest of the queue. + */ + break; + } + } /* end for each tx_buffer */ - ifp = &adapter->interface_data.ac_if; + ifp = &adapter->interface_data.ac_if; - /* Tell the stack that it is OK to send packets */ - if (adapter->num_tx_desc_avail > TX_CLEANUP_THRESHOLD) { - ifp->if_timer = 0; - ifp->if_flags &= ~IFF_OACTIVE; - } - splx(s); - return; + /* Tell the stack that it is OK to send packets */ + if (adapter->num_tx_desc_avail > TX_CLEANUP_THRESHOLD) { + ifp->if_timer = 0; + ifp->if_flags &= ~IFF_OACTIVE; + } + splx(s); + return; } Index: stable/4/sys/dev/em/if_em.h =================================================================== --- stable/4/sys/dev/em/if_em.h (revision 98399) +++ stable/4/sys/dev/em/if_em.h (revision 98400) @@ -1,247 +1,250 @@ /************************************************************************** Copyright (c) 2001-2002 Intel Corporation All rights reserved. Redistribution and use in source and binary forms of the Software, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code of the Software may retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form of the Software may reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the Intel Corporation nor the names of its contributors shall be used to endorse or promote products derived from this Software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ /*$FreeBSD$*/ #ifndef _EM_H_DEFINED_ #define _EM_H_DEFINED_ #include #include #include #include #include #include #include +#include #include +#include +#include #include #include + #include -#include -#include -#include +#include +#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "opt_bdg.h" -#include -#include +#include /* Tunables */ #define MAX_TXD 256 #define MAX_RXD 256 #define TX_CLEANUP_THRESHOLD MAX_TXD / 8 #define TIDV 128 #define RIDV 28 #define DO_AUTO_NEG 1 #define WAIT_FOR_AUTO_NEG_DEFAULT 1 #define AUTONEG_ADV_DEFAULT (ADVERTISE_10_HALF | ADVERTISE_10_FULL | \ ADVERTISE_100_HALF | ADVERTISE_100_FULL | \ ADVERTISE_1000_FULL) #define EM_ENABLE_RXCSUM_OFFLOAD 1 #define EM_REPORT_TX_EARLY 2 #define EM_CHECKSUM_FEATURES (CSUM_TCP | CSUM_UDP) #define EM_MAX_INTR 3 #define EM_TX_TIMEOUT 5 /* set to 5 seconds */ #define EM_VENDOR_ID 0x8086 #define EM_MMBA 0x0010 /* Mem base address */ #define EM_ROUNDUP(size, unit) (((size) + (unit) - 1) & ~((unit) - 1)) #define EM_JUMBO_PBA 0x00000028 #define EM_DEFAULT_PBA 0x00000030 #define IOCTL_CMD_TYPE u_long #define MAX_NUM_MULTICAST_ADDRESSES 128 #define PCI_ANY_ID (~0U) #define ETHER_ALIGN 2 +#define QTAG_TYPE 0x8100 /* Defines for printing debug information */ #define DEBUG_INIT 0 #define DEBUG_IOCTL 0 #define DEBUG_HW 0 #define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n") #define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A) #define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B) #define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n") #define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A) #define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B) #define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n") #define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A) #define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B) /* Supported RX Buffer Sizes */ #define EM_RXBUFFER_2048 2048 #define EM_RXBUFFER_4096 4096 #define EM_RXBUFFER_8192 8192 #define EM_RXBUFFER_16384 16384 #ifdef __alpha__ -#undef vtophys -#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) + #undef vtophys + #define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) #endif /* __alpha__ */ /* ****************************************************************************** * vendor_info_array * * This array contains the list of Subvendor/Subdevice IDs on which the driver * should load. * * ******************************************************************************/ typedef struct _em_vendor_info_t { - unsigned int vendor_id; - unsigned int device_id; - unsigned int subvendor_id; - unsigned int subdevice_id; - unsigned int index; + unsigned int vendor_id; + unsigned int device_id; + unsigned int subvendor_id; + unsigned int subdevice_id; + unsigned int index; } em_vendor_info_t; struct em_tx_buffer { - STAILQ_ENTRY(em_tx_buffer) em_tx_entry; - struct mbuf *m_head; - u_int32_t num_tx_desc_used; + STAILQ_ENTRY(em_tx_buffer) em_tx_entry; + struct mbuf *m_head; + u_int32_t num_tx_desc_used; }; /* ****************************************************************************** * This structure stores information about the 2k aligned receive buffer * into which the E1000 DMA's frames. * ******************************************************************************/ struct em_rx_buffer { - STAILQ_ENTRY(em_rx_buffer) em_rx_entry; - struct mbuf *m_head; - u_int64_t buffer_addr; + STAILQ_ENTRY(em_rx_buffer) em_rx_entry; + struct mbuf *m_head; + u_int64_t buffer_addr; }; typedef enum _XSUM_CONTEXT_T { - OFFLOAD_NONE, - OFFLOAD_TCP_IP, - OFFLOAD_UDP_IP + OFFLOAD_NONE, + OFFLOAD_TCP_IP, + OFFLOAD_UDP_IP } XSUM_CONTEXT_T; /* Our adapter structure */ struct adapter { - struct arpcom interface_data; - struct adapter *next; - struct adapter *prev; - struct em_shared_adapter shared; + struct arpcom interface_data; + struct adapter *next; + struct adapter *prev; + struct em_hw hw; - /* FreeBSD operating-system-specific structures */ - struct em_osdep osdep; - struct device *dev; - struct resource *res_memory; - struct resource *res_interrupt; - void *int_handler_tag; - struct ifmedia media; - struct callout_handle timer_handle; - u_int8_t unit; + /* FreeBSD operating-system-specific structures */ + struct em_osdep osdep; + struct device *dev; + struct resource *res_memory; + struct resource *res_interrupt; + void *int_handler_tag; + struct ifmedia media; + struct callout_handle timer_handle; + u_int8_t unit; - /* Info about the board itself */ - u_int32_t part_num; - u_int8_t link_active; - u_int16_t link_speed; - u_int16_t link_duplex; - u_int32_t tx_int_delay; - u_int32_t rx_int_delay; + /* Info about the board itself */ + u_int32_t part_num; + u_int8_t link_active; + u_int16_t link_speed; + u_int16_t link_duplex; + u_int32_t tx_int_delay; + u_int32_t rx_int_delay; - u_int8_t rx_checksum; - XSUM_CONTEXT_T active_checksum_context; + u_int8_t rx_checksum; + XSUM_CONTEXT_T active_checksum_context; - /* Transmit definitions */ - struct em_tx_desc *first_tx_desc; - struct em_tx_desc *last_tx_desc; - struct em_tx_desc *next_avail_tx_desc; - struct em_tx_desc *oldest_used_tx_desc; - struct em_tx_desc *tx_desc_base; - volatile u_int16_t num_tx_desc_avail; - u_int16_t num_tx_desc; - u_int32_t txd_cmd; - struct em_tx_buffer *tx_buffer_area; - STAILQ_HEAD(__em_tx_buffer_free, em_tx_buffer) free_tx_buffer_list; - STAILQ_HEAD(__em_tx_buffer_used, em_tx_buffer) used_tx_buffer_list; + /* Transmit definitions */ + struct em_tx_desc *first_tx_desc; + struct em_tx_desc *last_tx_desc; + struct em_tx_desc *next_avail_tx_desc; + struct em_tx_desc *oldest_used_tx_desc; + struct em_tx_desc *tx_desc_base; + volatile u_int16_t num_tx_desc_avail; + u_int16_t num_tx_desc; + u_int32_t txd_cmd; + struct em_tx_buffer *tx_buffer_area; + STAILQ_HEAD(__em_tx_buffer_free, em_tx_buffer) free_tx_buffer_list; + STAILQ_HEAD(__em_tx_buffer_used, em_tx_buffer) used_tx_buffer_list; - /* Receive definitions */ - struct em_rx_desc *first_rx_desc; - struct em_rx_desc *last_rx_desc; - struct em_rx_desc *next_rx_desc_to_check; - struct em_rx_desc *rx_desc_base; - u_int16_t num_rx_desc; - u_int32_t rx_buffer_len; - struct em_rx_buffer *rx_buffer_area; - STAILQ_HEAD(__em_rx_buffer, em_rx_buffer) rx_buffer_list; + /* Receive definitions */ + struct em_rx_desc *first_rx_desc; + struct em_rx_desc *last_rx_desc; + struct em_rx_desc *next_rx_desc_to_check; + struct em_rx_desc *rx_desc_base; + u_int16_t num_rx_desc; + u_int32_t rx_buffer_len; + struct em_rx_buffer *rx_buffer_area; + STAILQ_HEAD(__em_rx_buffer, em_rx_buffer) rx_buffer_list; - /* Jumbo frame */ - struct mbuf *fmp; - struct mbuf *lmp; + /* Jumbo frame */ + struct mbuf *fmp; + struct mbuf *lmp; - /* Misc stats maintained by the driver */ - unsigned long dropped_pkts; - unsigned long mbuf_alloc_failed; - unsigned long mbuf_cluster_failed; - unsigned long xmit_pullup; - unsigned long no_tx_desc_avail; - unsigned long no_tx_buffer_avail1; - unsigned long no_tx_buffer_avail2; -#ifdef DBG_STATS - unsigned long no_pkts_avail; - unsigned long clean_tx_interrupts; + /* Misc stats maintained by the driver */ + unsigned long dropped_pkts; + unsigned long mbuf_alloc_failed; + unsigned long mbuf_cluster_failed; + unsigned long xmit_pullup; + unsigned long no_tx_desc_avail; + unsigned long no_tx_buffer_avail1; + unsigned long no_tx_buffer_avail2; +#ifdef DBG_STATS + unsigned long no_pkts_avail; + unsigned long clean_tx_interrupts; #endif - struct em_shared_stats stats; + struct em_hw_stats stats; }; #endif /* _EM_H_DEFINED_ */ Index: stable/4/sys/dev/em/if_em_osdep.h =================================================================== --- stable/4/sys/dev/em/if_em_osdep.h (revision 98399) +++ stable/4/sys/dev/em/if_em_osdep.h (revision 98400) @@ -1,135 +1,135 @@ /************************************************************************** Copyright (c) 2001-2002 Intel Corporation All rights reserved. Redistribution and use in source and binary forms of the Software, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code of the Software may retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form of the Software may reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the Intel Corporation nor the names of its contributors shall be used to endorse or promote products derived from this Software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ /*$FreeBSD$*/ #ifndef _FREEBSD_OS_H_ #define _FREEBSD_OS_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ASSERT(x) if(!(x)) panic("EM: x") /* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */ #define usec_delay(x) DELAY(x) #define msec_delay(x) DELAY(1000*(x)) #define MSGOUT(S, A, B) printf(S "\n", A, B) #define DEBUGFUNC(F) DEBUGOUT(F); #if DBG - #define DEBUGOUT(S) printf(S "\n") - #define DEBUGOUT1(S,A) printf(S "\n",A) - #define DEBUGOUT2(S,A,B) printf(S "\n",A,B) - #define DEBUGOUT3(S,A,B,C) printf(S "\n",A,B,C) - #define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S "\n",A,B,C,D,E,F,G) + #define DEBUGOUT(S) printf(S "\n") + #define DEBUGOUT1(S,A) printf(S "\n",A) + #define DEBUGOUT2(S,A,B) printf(S "\n",A,B) + #define DEBUGOUT3(S,A,B,C) printf(S "\n",A,B,C) + #define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S "\n",A,B,C,D,E,F,G) #else - #define DEBUGOUT(S) - #define DEBUGOUT1(S,A) - #define DEBUGOUT2(S,A,B) - #define DEBUGOUT3(S,A,B,C) - #define DEBUGOUT7(S,A,B,C,D,E,F,G) + #define DEBUGOUT(S) + #define DEBUGOUT1(S,A) + #define DEBUGOUT2(S,A,B) + #define DEBUGOUT3(S,A,B,C) + #define DEBUGOUT7(S,A,B,C,D,E,F,G) #endif #define FALSE 0 #define TRUE 1 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */ #define PCI_COMMAND_REGISTER PCIR_COMMAND struct em_osdep { - bus_space_tag_t bus_space_tag; - bus_space_handle_t bus_space_handle; - struct device *dev; + bus_space_tag_t bus_space_tag; + bus_space_handle_t bus_space_handle; + struct device *dev; }; #define E1000_READ_REG(a, reg) (\ ((a)->mac_type >= em_82543) ? \ bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ E1000_##reg): \ bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ E1000_82542_##reg)) #define E1000_WRITE_REG(a, reg, value) (\ ((a)->mac_type >= em_82543) ? \ bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ E1000_##reg, value): \ bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ E1000_82542_##reg, value)) #define E1000_READ_REG_ARRAY(a, reg, offset) (\ ((a)->mac_type >= em_82543) ? \ bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ (E1000_##reg + ((offset) << 2))): \ bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ (E1000_82542_##reg + ((offset) << 2)))) #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) (\ ((a)->mac_type >= em_82543) ? \ bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ (E1000_##reg + ((offset) << 2)), value): \ bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \ ((struct em_osdep *)(a)->back)->bus_space_handle, \ (E1000_82542_##reg + ((offset) << 2)), value)) #endif /* _FREEBSD_OS_H_ */ Index: stable/4/sys/modules/em/Makefile =================================================================== --- stable/4/sys/modules/em/Makefile (revision 98399) +++ stable/4/sys/modules/em/Makefile (revision 98400) @@ -1,13 +1,12 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../dev/em -KMOD = if_em -SRCS = device_if.h bus_if.h pci_if.h opt_bdg.h -SRCS += if_em.c if_em_fxhw.c if_em_phy.c +#$FreeBSD$ +.PATH: ${.CURDIR}/../../dev/em +KMOD = if_em +SRCS = device_if.h bus_if.h pci_if.h opt_bdg.h +SRCS += if_em.c if_em_hw.c clean: rm -f opt_bdg.h device_if.h bus_if.h pci_if.h setdef* rm -f *.o *.kld *.ko rm -f @ machine .include