ipro1000: added ETHER_GET_LINK_STATE support

* use em_media_status to get link status
 * added IFM_1000_SX (Fiber Optic) to net/if_media.h


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20551 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Hugo Santos
2007-04-04 12:50:54 +00:00
parent c57dbb8b04
commit 36883c5516
4 changed files with 23 additions and 12 deletions
+1
View File
@@ -29,6 +29,7 @@
#define IFM_10_T 3 /* 10Base-T - RJ45 */ #define IFM_10_T 3 /* 10Base-T - RJ45 */
#define IFM_100_TX 6 /* 100Base-TX - RJ45 */ #define IFM_100_TX 6 /* 100Base-TX - RJ45 */
#define IFM_1000_T 16 /* 1000Base-T - RJ45 */ #define IFM_1000_T 16 /* 1000Base-T - RJ45 */
#define IFM_1000_SX 18 /* 1000Base-SX - Fiber Optic */
/* General options */ /* General options */
@@ -43,6 +43,7 @@ static int32 gOpenMask = 0;
int em_attach(device_t); int em_attach(device_t);
int em_detach(device_t); int em_detach(device_t);
void em_media_status(struct ifnet *, struct ifmediareq *);
static void static void
@@ -338,20 +339,28 @@ ipro1000_control(void *cookie, uint32 op, void *arg, size_t len)
return B_OK; return B_OK;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU #ifdef HAIKU_TARGET_PLATFORM_HAIKU
#if 0
case ETHER_GET_LINK_STATE: case ETHER_GET_LINK_STATE:
{ {
struct ifnet ifp = { .if_softc = device->adapter };
struct ifmediareq mediareq;
ether_link_state_t state; ether_link_state_t state;
state.media = (info->link ? IFM_ACTIVE : 0)
| (info->full_duplex ? IFM_FULL_DUPLEX : IFM_HALF_DUPLEX) if (len < sizeof(ether_link_state_t))
| (info->speed == LINK_SPEED_100_MBIT ? IFM_100_TX : IFM_10_T); return ENOBUFS;
state.speed = info->speed == LINK_SPEED_100_MBIT
? 100000 : 10000; em_media_status(&ifp, &mediareq);
state.media = mediareq.ifm_active;
if (mediareq.ifm_active & IFM_10_T)
state.speed = 10000;
else if (mediareq.ifm_active & IFM_100_TX)
state.speed = 100000;
else
state.speed = 1000000;
state.quality = 1000; state.quality = 1000;
return user_memcpy(buffer, &state, sizeof(ether_link_state_t)); return user_memcpy(arg, &state, sizeof(ether_link_state_t));
} }
#endif
#endif #endif
default: default:
@@ -20,6 +20,7 @@
#define __IF_COMPAT_H #define __IF_COMPAT_H
#include <OS.h> #include <OS.h>
#include <net/if_media.h>
#define __FreeBSD_version 500001 #define __FreeBSD_version 500001
@@ -39,10 +40,10 @@
#define IFCAP_RXCSUM 0x0020 #define IFCAP_RXCSUM 0x0020
#ifdef HAIKU_TARGET_PLATFORM_HAIKU #ifdef HAIKU_TARGET_PLATFORM_HAIKU
# define IFM_AVALID 0
# define IFM_FDX IFM_FULL_DUPLEX # define IFM_FDX IFM_FULL_DUPLEX
# define IFM_HDX IFM_HALF_DUPLEX # define IFM_HDX IFM_HALF_DUPLEX
# define IFM_1000_TX 17 # define IFM_1000_TX IFM_1000_T
# define IFM_1000_SX 18
#else #else
# define IFM_ACTIVE 0x0001 # define IFM_ACTIVE 0x0001
# define IFM_FDX 0x0002 # define IFM_FDX 0x0002
@@ -814,7 +814,6 @@ event_handler(void *cookie)
} }
#if 0
/********************************************************************* /*********************************************************************
* *
* Media Ioctl callback * Media Ioctl callback
@@ -823,7 +822,7 @@ event_handler(void *cookie)
* the interface using ifconfig. * the interface using ifconfig.
* *
**********************************************************************/ **********************************************************************/
static void void
em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
{ {
struct adapter * adapter = ifp->if_softc; struct adapter * adapter = ifp->if_softc;
@@ -880,6 +879,7 @@ em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
return; return;
} }
#if 0
/********************************************************************* /*********************************************************************
* *
* Media Ioctl callback * Media Ioctl callback