Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Aug 1997 18:16:02 +0200
From:      Thomas Berndes <thobe@cs.tu-berlin.de>
To:        questions FreeBSD Org <freebsd-questions@FreeBSD.org>
Subject:   Problems developing a network-driver as an kernel-module
Message-ID:  <3401AFC1.885739D2@cs.tu-berlin.de>

next in thread | raw e-mail | index | archive | help

--------------FD6B95DC4A0149B0099D90AE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello FreeBSD-Programmers,

I have a problem, while developing a network-driver for FreeBSD (2.2.1).

The driver, i have written, works fine when linked static with the
kernel, but something failes when using it as a kernel-module (LKM).


   * Has anybody a suggestion, about the reason for that failure ??



   * Where can i get more doc about the LKM's ?



   * Has anybody written a <if_detach()> function, so i can
     unregisterand unload my driver, which registered with the
     <if_attach()> function ?

regards,

  Thomas Berndes



======================================================================

The next few lines are describing the appearance of the failure:

  bash# modload ....  -> OK

  bash# ifconfig Date0 inet 101.102.103.1 101.102.103.2 netmask
255.255.255.0
  bash# route add -net 101.102.103.0 -netmask 255.255.255.0 -interface
Date0
  add net 101.102.103.0: gateway Date0

  bash# ping 101.102.103.22
  PING 101.102.103.22 (101.102.103.22): 56 data bytes
  ping: sendto: No buffer space available
  ping: wrote 101.102.103.22 64 chars, ret=-1
  ping: sendto: No buffer space available
  ping: wrote 101.102.103.22 64 chars, ret=-1
  ^C
  --- 101.102.103.22 ping statistics ---
  2 packets transmitted, 0 packets received, 100% packet loss



======================================================================

The following lines are an extract from the source-code of the driver.

/* the real initialization of HW and driver */
uDDK_init_driver( ... ){
  ...

  uDDK_P_ifp.if_name   = pinfo->name;
  uDDK_P_ifp.if_unit   = 0;
  uDDK_P_ifp.if_mtu    = 1500;
  uDDK_P_ifp.if_output = uDDK_P_write;
  uDDK_P_ifp.if_flags  = IFF_POINTOPOINT | IFF_MULTICAST;

  if_attach( &uDDK_P_ifp );

  printf( "%s: Driver initialized\n", pdriver_info->name );
  return uDDK_INIT_DRIVER_OK;
}

struct isa_driver Datedriver = {uDDK_P_probe, uDDK_P_attach, "Date"};

uDDK_Init_Type
Date_init( uDDK_INIT_ARGS )
{
  if( uDDK_init_driver( ... )
}

PSEUDO_SET( Date_init, Date );



#ifdef MODULE

MOD_MISC ( Date );

int init_module( uDDK_MODULE_ARGS )
{
  if( uDDK_init_driver( ... )
}

...

#endif  /* MODULE */




--------------FD6B95DC4A0149B0099D90AE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hello FreeBSD-Programmers,

<P>I have a problem, while developing a network-driver for FreeBSD (2.2.1).

<P>The driver, i have written, works fine when linked static with the
<BR>kernel, but something failes when using it as a kernel-module (LKM).
<BR>&nbsp;
<UL>
<LI>
Has anybody a suggestion, about the reason for that failure ??</LI>
</UL>
&nbsp;
<UL>
<LI>
Where can i get more doc about the LKM's ?</LI>
</UL>
&nbsp;
<UL>
<LI>
Has anybody written a &lt;if_detach()> function, so i can unregisterand
unload my driver, which registered with the &lt;if_attach()> function ?</LI>
</UL>


<P>regards,

<P>&nbsp; Thomas Berndes
<BR>&nbsp;
<BR>&nbsp;

<P>======================================================================

<P>The next few lines are describing the appearance of the failure:

<P>&nbsp; bash# modload ....&nbsp; -> OK

<P>&nbsp; bash# ifconfig Date0 inet 101.102.103.1 101.102.103.2 netmask
255.255.255.0
<BR>&nbsp; bash# route add -net 101.102.103.0 -netmask 255.255.255.0 -interface
Date0
<BR>&nbsp; add net 101.102.103.0: gateway Date0
<BR>&nbsp;
<BR>&nbsp; bash# ping 101.102.103.22
<BR>&nbsp; PING 101.102.103.22 (101.102.103.22): 56 data bytes
<BR>&nbsp; ping: sendto: No buffer space available
<BR>&nbsp; ping: wrote 101.102.103.22 64 chars, ret=-1
<BR>&nbsp; ping: sendto: No buffer space available
<BR>&nbsp; ping: wrote 101.102.103.22 64 chars, ret=-1
<BR>&nbsp; ^C
<BR>&nbsp; --- 101.102.103.22 ping statistics ---
<BR>&nbsp; 2 packets transmitted, 0 packets received, 100% packet loss
<BR>&nbsp;
<BR>&nbsp;

<P>======================================================================

<P>The following lines are an extract from the source-code of the driver.

<P>/* the real initialization of HW and driver */
<BR>uDDK_init_driver( ... ){
<BR>&nbsp; ...

<P>&nbsp; uDDK_P_ifp.if_name&nbsp;&nbsp; = pinfo->name;
<BR>&nbsp; uDDK_P_ifp.if_unit&nbsp;&nbsp; = 0;
<BR>&nbsp; uDDK_P_ifp.if_mtu&nbsp;&nbsp;&nbsp; = 1500;
<BR>&nbsp; uDDK_P_ifp.if_output = uDDK_P_write;
<BR>&nbsp; uDDK_P_ifp.if_flags&nbsp; = IFF_POINTOPOINT | IFF_MULTICAST;

<P>&nbsp; if_attach( &amp;uDDK_P_ifp );

<P>&nbsp; printf( "%s: Driver initialized\n", pdriver_info->name );
<BR>&nbsp; return uDDK_INIT_DRIVER_OK;
<BR>}

<P>struct isa_driver Datedriver = {uDDK_P_probe, uDDK_P_attach, "Date"};

<P>uDDK_Init_Type
<BR>Date_init( uDDK_INIT_ARGS )
<BR>{
<BR>&nbsp; if( uDDK_init_driver( ... )
<BR>}

<P>PSEUDO_SET( Date_init, Date );
<BR>&nbsp;
<BR>&nbsp;

<P>#ifdef MODULE

<P>MOD_MISC ( Date );

<P>int init_module( uDDK_MODULE_ARGS )
<BR>{
<BR>&nbsp; if( uDDK_init_driver( ... )
<BR>}

<P>...

<P>#endif&nbsp; /* MODULE */
<BR>&nbsp;
<BR>&nbsp;
<BR>&nbsp;</HTML>

--------------FD6B95DC4A0149B0099D90AE--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3401AFC1.885739D2>