From a34967de860ba059df8274413c3ae9bc570ca3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 3 Apr 2007 14:57:28 +0000 Subject: [PATCH] Prepared implementation of ETHER_GETLINKSTATE - it would need a bit more work to get it to work as intended, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20537 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/network/ipro1000/device.c | 42 ++++++++++++++----- .../drivers/network/ipro1000/if_compat.h | 41 ++++++++++-------- .../drivers/network/ipro1000/if_em_osdep.h | 14 ++++--- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/src/add-ons/kernel/drivers/network/ipro1000/device.c b/src/add-ons/kernel/drivers/network/ipro1000/device.c index b0f07e0a01..1df1aeec15 100644 --- a/src/add-ons/kernel/drivers/network/ipro1000/device.c +++ b/src/add-ons/kernel/drivers/network/ipro1000/device.c @@ -16,13 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include + #include "debug.h" #include "device.h" @@ -31,6 +25,17 @@ #include "if_em.h" #include "if_compat.h" +#include +#include + +#include +#include +#include +#include +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +# include +#endif + #undef malloc #undef free @@ -331,11 +336,28 @@ ipro1000_control(void *cookie, uint32 op, void *arg, size_t len) DEVICE_DEBUGOUT2("ipro1000_control() ETHER_GETFRAMESIZE, framesize = %d (MTU = %d)", device->maxframesize, device->maxframesize - ENET_HEADER_SIZE); *(uint32*)arg = device->maxframesize; return B_OK; - + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +#if 0 + case ETHER_GETLINKSTATE: + { + ether_link_state_t state; + state.link_media = (info->link ? IFM_ACTIVE : 0) + | (info->full_duplex ? IFM_FULL_DUPLEX : IFM_HALF_DUPLEX) + | (info->speed == LINK_SPEED_100_MBIT ? IFM_100_TX : IFM_10_T); + state.link_speed = info->speed == LINK_SPEED_100_MBIT + ? 100000 : 10000; + state.link_quality = 1000; + + return user_memcpy(buffer, &state, sizeof(ether_link_state_t)); + } +#endif +#endif + default: DEVICE_DEBUGOUT("ipro1000_control() Invalid command"); break; } - - return B_ERROR; + + return B_BAD_VALUE; } diff --git a/src/add-ons/kernel/drivers/network/ipro1000/if_compat.h b/src/add-ons/kernel/drivers/network/ipro1000/if_compat.h index 0cd593ce19..157ec35a2b 100644 --- a/src/add-ons/kernel/drivers/network/ipro1000/if_compat.h +++ b/src/add-ons/kernel/drivers/network/ipro1000/if_compat.h @@ -38,23 +38,30 @@ #define IFCAP_TXCSUM 0x0010 #define IFCAP_RXCSUM 0x0020 -#define IFM_ACTIVE 0x0001 -#define IFM_FDX 0x0002 -#define IFM_HDX 0x0004 -#define IFM_10_T 0x0008 -#define IFM_100_TX 0x0010 -#define IFM_1000_T 0x0020 -#define IFM_1000_TX 0x0040 -#define IFM_1000_SX 0x0080 -#define IFM_ETHER 0x0100 -#define IFM_AUTO 0x0200 -#define IFM_AVALID 0x0400 -#define IFM_GMASK (IFM_FDX | IFM_HDX) -#define IFM_TYPE_MASK (IFM_ETHER) -#define IFM_SUBTYPE_MASK (IFM_AUTO | IFM_1000_SX | IFM_1000_TX | IFM_1000_T | IFM_100_TX | IFM_10_T) - -#define IFM_TYPE(media) ((media) & IFM_TYPE_MASK) -#define IFM_SUBTYPE(media) ((media) & IFM_SUBTYPE_MASK) +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +# define IFM_FDX IFM_FULL_DUPLEX +# define IFM_HDX IFM_HALF_DUPLEX +# define IFM_1000_TX 17 +# define IFM_1000_SX 18 +#else +# define IFM_ACTIVE 0x0001 +# define IFM_FDX 0x0002 +# define IFM_HDX 0x0004 +# define IFM_10_T 0x0008 +# define IFM_100_TX 0x0010 +# define IFM_1000_T 0x0020 +# define IFM_1000_TX 0x0040 +# define IFM_1000_SX 0x0080 +# define IFM_ETHER 0x0100 +# define IFM_AUTO 0x0200 +# define IFM_AVALID 0x0400 +# define IFM_GMASK (IFM_FDX | IFM_HDX) +# define IFM_TYPE_MASK (IFM_ETHER) +# define IFM_SUBTYPE_MASK \ + (IFM_AUTO | IFM_1000_SX | IFM_1000_TX | IFM_1000_T | IFM_100_TX | IFM_10_T) +# define IFM_TYPE(media) ((media) & IFM_TYPE_MASK) +# define IFM_SUBTYPE(media) ((media) & IFM_SUBTYPE_MASK) +#endif #define CSUM_TCP 0x0001 // ifnet::if_hwassist #define CSUM_UDP 0x0002 // ifnet::if_hwassist diff --git a/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.h b/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.h index db384243fb..5a0e87ac00 100644 --- a/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.h +++ b/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.h @@ -34,17 +34,19 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef _IF_EM_OSDEP_H_ #define _IF_EM_OSDEP_H_ -#include -#include -#include -#include -#include -#include #include "driver.h" #include "device.h" #include "timer.h" #include "debug.h" +#include +#include +#include + +#include +#include +#include + #define usec_delay(x) snooze(x) #define msec_delay(x) snooze(1000*(x))