source: rtems/cpukit/libnetworking/rtems/rtems_mii_ioctl.h @ 05cdf2a8

4.104.114.84.95
Last change on this file since 05cdf2a8 was 05cdf2a8, checked in by Till Straumann <strauman@…>, on 01/17/07 at 06:15:19

2007-01-16 Till Straumann <strauman@…>

  • libnetworking/rtems/rtems_mii_ioctl.c,
  • libnetworking/rtems/rtems_mii_ioctl.h,
  • libnetworking/rtems/rtems_mii_ioctl_kern.c: Added SLAC/Stanford Authorship Note / Copyright + Liability Disclaimer.
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/* Simple (default) implementation for SIOCGIFMEDIA/SIOCSIFMEDIA
2 * to be used by ethernet drivers [from their ioctl].
3 *
4 * NOTE: This much simpler than the BSD ifmedia API
5 *
6 *  $Id$
7 */
8
9/*
10 * Authorship
11 * ----------
12 * This software was created by
13 *     Till Straumann <strauman@slac.stanford.edu>, 2005,
14 *         Stanford Linear Accelerator Center, Stanford University.
15 *
16 * Acknowledgement of sponsorship
17 * ------------------------------
18 * This software was produced by
19 *     the Stanford Linear Accelerator Center, Stanford University,
20 *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
21 *
22 * Government disclaimer of liability
23 * ----------------------------------
24 * Neither the United States nor the United States Department of Energy,
25 * nor any of their employees, makes any warranty, express or implied, or
26 * assumes any legal liability or responsibility for the accuracy,
27 * completeness, or usefulness of any data, apparatus, product, or process
28 * disclosed, or represents that its use would not infringe privately owned
29 * rights.
30 *
31 * Stanford disclaimer of liability
32 * --------------------------------
33 * Stanford University makes no representations or warranties, express or
34 * implied, nor assumes any liability for the use of this software.
35 *
36 * Stanford disclaimer of copyright
37 * --------------------------------
38 * Stanford University, owner of the copyright, hereby disclaims its
39 * copyright and all other rights in this software.  Hence, anyone may
40 * freely use it for any purpose without restriction. 
41 *
42 * Maintenance of notices
43 * ----------------------
44 * In the interest of clarity regarding the origin and status of this
45 * SLAC software, this and all the preceding Stanford University notices
46 * are to remain affixed to any copy or derivative of this software made
47 * or distributed by the recipient and are to be affixed to any copy of
48 * software made or distributed by the recipient that contains a copy or
49 * derivative of this software.
50 *
51 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
52 */
53#ifndef RTEMS_MII_IOCTL_H
54#define RTEMS_MII_IOCTL_H
55
56#include <dev/mii/mii.h>    /* MII register definitions                                */
57#include <net/if_media.h>   /* media word definitions; rest of API (ifmedia) unused!   */
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63#if defined(_KERNEL) || defined(KERNEL) || \
64    defined(__KERNEL) || defined(__KERNEL__)
65/* mdio routines to be provided by driver */
66
67/* read mii register 'reg' at 'phy' (-1 meaning any/currently active)
68 * RETURNS 0 on success, -1 otherwise (e.g., illegal phy)
69 */
70typedef int (*rtems_mdio_read_func) (int phy, void *uarg, unsigned reg,
71                                     uint32_t * pval);
72
73/* write mii register 'reg' at 'phy' (-1 meaning any/currently active)
74 * RETURNS 0 on success, -1 otherwise (e.g., illegal phy)
75 */
76typedef int (*rtems_mdio_write_func) (int phy, void *uarg, unsigned reg,
77                                      uint32_t val);
78
79/* Values to this must be provided by the driver */
80struct rtems_mdio_info {
81  rtems_mdio_read_func mdio_r;
82  rtems_mdio_write_func mdio_w;
83  unsigned has_gmii:1;          /* supports gigabit */
84};
85
86/* Implement SIOCSIFMEDIA/SIOCGIFMEDIA; get/set the current media word. Note
87 * that this does NOT implement the full BSD 'ifmedia' API; also, it only
88 * implements IFM_ETHER...
89 *
90 * INPUT:
91 *    SIOCGIFMEDIA: the media word must set the phy instance (-1 for 'any')
92 *
93 */
94int
95rtems_mii_ioctl (struct rtems_mdio_info *info, void *uarg, int cmd,
96                 int *media);
97
98#endif
99
100/* The driver flags have the following meaning (SIOCGIFMEDIA only):
101 */
102#define IFM_LINK_OK             IFM_FLAG0
103#define IFM_ANEG_DIS    IFM_FLAG1       /* autoneg. disabled; media forced */
104
105/* convert a media word to a string;
106 *
107 * RETURNS: number of characters written to 'buf'
108 *
109 * INPUT:   if 'bufsz' is set to IFMEDIA2STR_PRINT_TO_FILE, 'buf' can be a FILE
110 *          pointer where the info is printed insted. This can be NULL in which
111 *          case 'stdout' is used.
112 */
113
114#define IFMEDIA2STR_PRINT_TO_FILE       0
115
116int rtems_ifmedia2str (int media, char *buf, int bufsz);
117
118/* convert a string to a media word
119 * RETURNS: 0 on failure (unrecognized or invalid mode);
120 *          valid results have always at least IFM_ETHER set.
121 *
122 * In addition to IFM_SUBTYPE_ETHERNET_DESCRIPTIONS and
123 * IFM_SUBTYPE_ETHERNET_ALIASES, the strings
124 *
125 *  '10' [ '0' [ '0' ]] 'b' [ 'ase' ] ( 't' | 'T' )
126 *           (* if 100bT [ 'x' | 'X' ] is required here *)
127 *
128 * are recognized (e.g., 10bT, 100bTX)
129 *
130 * if any of the strings 'full' or 'FDX' or 'fdx' is present, a full-duplex mode
131 * is selected (half-duplex otherwise).
132 *  e.g., '100bTx-full'
133 */
134
135int rtems_str2ifmedia (const char *str, int phy);
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif
Note: See TracBrowser for help on using the repository browser.