blob: f383ccce0b92e528df54c8bb02ae966b61bce813 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00002/*
Joe Hershbergerc7eceaf2015-03-22 17:09:10 -05003 * (C) Copyright 2001-2015
wdenkc6097192002-11-03 00:24:07 +00004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Joe Hershbergerc7eceaf2015-03-22 17:09:10 -05005 * Joe Hershberger, National Instruments
wdenkc6097192002-11-03 00:24:07 +00006 */
7
8#include <common.h>
Simon Glass1ea97892020-05-10 11:40:00 -06009#include <bootstage.h>
wdenkc6097192002-11-03 00:24:07 +000010#include <command.h>
Simon Glass992b6032020-07-19 10:15:39 -060011#include <dm.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060012#include <env.h>
Simon Glass0f2af882020-05-10 11:40:05 -060013#include <log.h>
wdenkc6097192002-11-03 00:24:07 +000014#include <net.h>
Andy Flemingaecf6fc2011-04-08 02:10:27 -050015#include <phy.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060016#include <asm/global_data.h>
Simon Glassc06c1be2020-05-10 11:40:08 -060017#include <linux/bug.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090018#include <linux/errno.h>
Ramon Friedac598c12019-07-18 21:43:30 +030019#include <net/pcap.h>
Simon Glass0a9bde12016-01-17 14:51:57 -070020#include "eth_internal.h"
wdenkc6097192002-11-03 00:24:07 +000021
Joe Hershberger3dbe17e2015-03-22 17:09:06 -050022DECLARE_GLOBAL_DATA_PTR;
23
Simon Glassb6121f22015-04-05 16:07:37 -060024/*
25 * CPU and board-specific Ethernet initializations. Aliased function
26 * signals caller to move on
27 */
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090028static int __def_eth_init(struct bd_info *bis)
Simon Glassb6121f22015-04-05 16:07:37 -060029{
30 return -1;
31}
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090032int cpu_eth_init(struct bd_info *bis) __attribute__((weak, alias("__def_eth_init")));
33int board_eth_init(struct bd_info *bis) __attribute__((weak, alias("__def_eth_init")));
Simon Glassb6121f22015-04-05 16:07:37 -060034
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +010035#ifdef CONFIG_API
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +010036static struct {
37 uchar data[PKTSIZE];
38 int length;
39} eth_rcv_bufs[PKTBUFSRX];
40
Joe Hershberger5956ded2012-05-15 08:59:07 +000041static unsigned int eth_rcv_current, eth_rcv_last;
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +010042#endif
43
Joe Hershberger9f374062012-08-03 10:59:08 +000044static struct eth_device *eth_devices;
45struct eth_device *eth_current;
wdenkc6097192002-11-03 00:24:07 +000046
Simon Glassd9582c32016-01-17 14:51:59 -070047void eth_set_current_to_next(void)
Joe Hershbergere1e8a8c2015-03-22 17:09:03 -050048{
49 eth_current = eth_current->next;
50}
51
Simon Glassd9582c32016-01-17 14:51:59 -070052void eth_set_dev(struct eth_device *dev)
Joe Hershberger279d2f62015-03-22 17:09:16 -050053{
54 eth_current = dev;
55}
56
Ben Warren97824d62010-07-29 12:56:11 -070057struct eth_device *eth_get_dev_by_name(const char *devname)
Marian Balakowiczaab8c492005-10-28 22:30:33 +020058{
59 struct eth_device *dev, *target_dev;
60
Helmut Raiger153bf3a2011-08-22 00:17:17 +000061 BUG_ON(devname == NULL);
62
Marian Balakowiczaab8c492005-10-28 22:30:33 +020063 if (!eth_devices)
64 return NULL;
65
66 dev = eth_devices;
67 target_dev = NULL;
68 do {
69 if (strcmp(devname, dev->name) == 0) {
70 target_dev = dev;
71 break;
72 }
73 dev = dev->next;
74 } while (dev != eth_devices);
75
76 return target_dev;
77}
78
Andy Fleminge7fd34b2009-02-11 15:07:24 -060079struct eth_device *eth_get_dev_by_index(int index)
80{
81 struct eth_device *dev, *target_dev;
Andy Fleminge7fd34b2009-02-11 15:07:24 -060082
83 if (!eth_devices)
84 return NULL;
85
86 dev = eth_devices;
87 target_dev = NULL;
88 do {
Michael Walle391da4c2011-10-27 11:31:35 +000089 if (dev->index == index) {
Andy Fleminge7fd34b2009-02-11 15:07:24 -060090 target_dev = dev;
91 break;
92 }
93 dev = dev->next;
Andy Fleminge7fd34b2009-02-11 15:07:24 -060094 } while (dev != eth_devices);
95
96 return target_dev;
97}
98
Joe Hershberger5956ded2012-05-15 08:59:07 +000099int eth_get_dev_index(void)
wdenkc6097192002-11-03 00:24:07 +0000100{
Joe Hershberger5956ded2012-05-15 08:59:07 +0000101 if (!eth_current)
Michael Walle391da4c2011-10-27 11:31:35 +0000102 return -1;
wdenkc6097192002-11-03 00:24:07 +0000103
Michael Walle391da4c2011-10-27 11:31:35 +0000104 return eth_current->index;
wdenkc6097192002-11-03 00:24:07 +0000105}
106
Joe Hershberger7e0b0152015-05-20 14:27:26 -0500107static int on_ethaddr(const char *name, const char *value, enum env_op op,
108 int flags)
109{
110 int index;
111 struct eth_device *dev;
112
113 if (!eth_devices)
114 return 0;
115
116 /* look for an index after "eth" */
Simon Glassff9b9032021-07-24 09:03:30 -0600117 index = dectoul(name + 3, NULL);
Joe Hershberger7e0b0152015-05-20 14:27:26 -0500118
119 dev = eth_devices;
120 do {
121 if (dev->index == index) {
122 switch (op) {
123 case env_op_create:
124 case env_op_overwrite:
Joe Hershberger8e7545e2019-09-13 19:21:16 -0500125 string_to_enetaddr(value, dev->enetaddr);
Marek Vasut0ef21482016-11-12 16:28:40 +0100126 eth_write_hwaddr(dev, "eth", dev->index);
Joe Hershberger7e0b0152015-05-20 14:27:26 -0500127 break;
128 case env_op_delete:
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100129 memset(dev->enetaddr, 0, ARP_HLEN);
Joe Hershberger7e0b0152015-05-20 14:27:26 -0500130 }
131 }
Gong Qianyua4f23972015-08-31 11:34:43 +0800132 dev = dev->next;
Joe Hershberger7e0b0152015-05-20 14:27:26 -0500133 } while (dev != eth_devices);
134
135 return 0;
136}
137U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);
138
Simon Glass62b36c92011-06-13 16:13:10 -0700139int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
140 int eth_number)
141{
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100142 unsigned char env_enetaddr[ARP_HLEN];
Simon Glass62b36c92011-06-13 16:13:10 -0700143 int ret = 0;
144
Simon Glass399a9ce2017-08-03 12:22:14 -0600145 eth_env_get_enetaddr_by_index(base_name, eth_number, env_enetaddr);
Simon Glass62b36c92011-06-13 16:13:10 -0700146
Joe Hershberger8ecdbed2015-04-08 01:41:04 -0500147 if (!is_zero_ethaddr(env_enetaddr)) {
148 if (!is_zero_ethaddr(dev->enetaddr) &&
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100149 memcmp(dev->enetaddr, env_enetaddr, ARP_HLEN)) {
Simon Glass62b36c92011-06-13 16:13:10 -0700150 printf("\nWarning: %s MAC addresses don't match:\n",
Joe Hershbergerc10c0b12015-04-08 01:41:19 -0500151 dev->name);
Simon Glass62b36c92011-06-13 16:13:10 -0700152 printf("Address in SROM is %pM\n",
Joe Hershbergerc10c0b12015-04-08 01:41:19 -0500153 dev->enetaddr);
Simon Glass62b36c92011-06-13 16:13:10 -0700154 printf("Address in environment is %pM\n",
Joe Hershbergerc10c0b12015-04-08 01:41:19 -0500155 env_enetaddr);
Simon Glass62b36c92011-06-13 16:13:10 -0700156 }
157
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100158 memcpy(dev->enetaddr, env_enetaddr, ARP_HLEN);
Joe Hershberger8ecdbed2015-04-08 01:41:04 -0500159 } else if (is_valid_ethaddr(dev->enetaddr)) {
Simon Glass8551d552017-08-03 12:22:11 -0600160 eth_env_set_enetaddr_by_index(base_name, eth_number,
161 dev->enetaddr);
Joe Hershberger8ecdbed2015-04-08 01:41:04 -0500162 } else if (is_zero_ethaddr(dev->enetaddr)) {
Joe Hershberger2dc2b5d2015-05-04 14:55:13 -0500163#ifdef CONFIG_NET_RANDOM_ETHADDR
164 net_random_ethaddr(dev->enetaddr);
165 printf("\nWarning: %s (eth%d) using random MAC address - %pM\n",
166 dev->name, eth_number, dev->enetaddr);
167#else
Pavel Machek222981f2014-07-13 10:27:02 +0200168 printf("\nError: %s address not set.\n",
169 dev->name);
170 return -EINVAL;
Joe Hershberger2dc2b5d2015-05-04 14:55:13 -0500171#endif
Simon Glass62b36c92011-06-13 16:13:10 -0700172 }
173
Pavel Machek222981f2014-07-13 10:27:02 +0200174 if (dev->write_hwaddr && !eth_mac_skip(eth_number)) {
Joe Hershberger8ecdbed2015-04-08 01:41:04 -0500175 if (!is_valid_ethaddr(dev->enetaddr)) {
Pavel Machek222981f2014-07-13 10:27:02 +0200176 printf("\nError: %s address %pM illegal value\n",
Joe Hershbergerc10c0b12015-04-08 01:41:19 -0500177 dev->name, dev->enetaddr);
Pavel Machek222981f2014-07-13 10:27:02 +0200178 return -EINVAL;
179 }
Benoît Thébaudeau050219e2012-08-10 07:56:21 +0000180
Simon Glass62b36c92011-06-13 16:13:10 -0700181 ret = dev->write_hwaddr(dev);
Pavel Machek222981f2014-07-13 10:27:02 +0200182 if (ret)
Joe Hershbergerc10c0b12015-04-08 01:41:19 -0500183 printf("\nWarning: %s failed to set MAC address\n",
184 dev->name);
Benoît Thébaudeau050219e2012-08-10 07:56:21 +0000185 }
Simon Glass62b36c92011-06-13 16:13:10 -0700186
187 return ret;
188}
189
Simon Glass1e9961d2011-02-16 11:14:33 -0800190int eth_register(struct eth_device *dev)
191{
192 struct eth_device *d;
Joe Hershberger5956ded2012-05-15 08:59:07 +0000193 static int index;
Michal Simek5b4945b2011-08-29 23:30:13 +0000194
Mike Frysinger6b300dc2011-11-10 14:11:04 +0000195 assert(strlen(dev->name) < sizeof(dev->name));
Michal Simek5b4945b2011-08-29 23:30:13 +0000196
Simon Glass1e9961d2011-02-16 11:14:33 -0800197 if (!eth_devices) {
Joe Hershbergerc10c0b12015-04-08 01:41:19 -0500198 eth_devices = dev;
199 eth_current = dev;
Simon Glass1e9961d2011-02-16 11:14:33 -0800200 eth_current_changed();
wdenkc6097192002-11-03 00:24:07 +0000201 } else {
Joe Hershberger5956ded2012-05-15 08:59:07 +0000202 for (d = eth_devices; d->next != eth_devices; d = d->next)
Detlev Zundeld46bcd32010-03-31 17:56:08 +0200203 ;
wdenkc6097192002-11-03 00:24:07 +0000204 d->next = dev;
205 }
206
207 dev->state = ETH_STATE_INIT;
208 dev->next = eth_devices;
Michael Walle391da4c2011-10-27 11:31:35 +0000209 dev->index = index++;
wdenkc6097192002-11-03 00:24:07 +0000210
211 return 0;
212}
213
Vincent Palatin451be502012-01-09 08:32:36 +0000214int eth_unregister(struct eth_device *dev)
215{
216 struct eth_device *cur;
217
218 /* No device */
219 if (!eth_devices)
Joe Hershbergerd0ce3412015-03-22 17:09:04 -0500220 return -ENODEV;
Vincent Palatin451be502012-01-09 08:32:36 +0000221
222 for (cur = eth_devices; cur->next != eth_devices && cur->next != dev;
223 cur = cur->next)
224 ;
225
226 /* Device not found */
227 if (cur->next != dev)
Joe Hershbergerd0ce3412015-03-22 17:09:04 -0500228 return -ENODEV;
Vincent Palatin451be502012-01-09 08:32:36 +0000229
230 cur->next = dev->next;
231
232 if (eth_devices == dev)
233 eth_devices = dev->next == eth_devices ? NULL : dev->next;
234
235 if (eth_current == dev) {
236 eth_current = eth_devices;
237 eth_current_changed();
238 }
239
240 return 0;
241}
242
Joe Hershberger3dbe17e2015-03-22 17:09:06 -0500243int eth_initialize(void)
wdenkc6097192002-11-03 00:24:07 +0000244{
Michael Walle391da4c2011-10-27 11:31:35 +0000245 int num_devices = 0;
Simon Glassb6121f22015-04-05 16:07:37 -0600246
wdenkc6097192002-11-03 00:24:07 +0000247 eth_devices = NULL;
248 eth_current = NULL;
Simon Glassb6121f22015-04-05 16:07:37 -0600249 eth_common_init();
Simon Glass0a9bde12016-01-17 14:51:57 -0700250 /*
251 * If board-specific initialization exists, call it.
252 * If not, call a CPU-specific one
253 */
254 if (board_eth_init != __def_eth_init) {
255 if (board_eth_init(gd->bd) < 0)
256 printf("Board Net Initialization Failed\n");
257 } else if (cpu_eth_init != __def_eth_init) {
258 if (cpu_eth_init(gd->bd) < 0)
259 printf("CPU Net Initialization Failed\n");
260 } else {
261 printf("Net Initialization Skipped\n");
262 }
Marian Balakowiczcbdd1c82005-11-30 18:06:04 +0100263
wdenkc6097192002-11-03 00:24:07 +0000264 if (!eth_devices) {
Heinrich Schuchardt653f3ee2020-09-14 11:00:18 +0200265 log_err("No ethernet found.\n");
Simon Glass0169e6b2012-02-13 13:51:18 +0000266 bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
wdenkc6097192002-11-03 00:24:07 +0000267 } else {
268 struct eth_device *dev = eth_devices;
Simon Glass64b723f2017-08-03 12:22:12 -0600269 char *ethprime = env_get("ethprime");
wdenkc6097192002-11-03 00:24:07 +0000270
Simon Glass0169e6b2012-02-13 13:51:18 +0000271 bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
wdenkc6097192002-11-03 00:24:07 +0000272 do {
Michael Walle391da4c2011-10-27 11:31:35 +0000273 if (dev->index)
Joe Hershberger5956ded2012-05-15 08:59:07 +0000274 puts(", ");
wdenkc6097192002-11-03 00:24:07 +0000275
276 printf("%s", dev->name);
277
Joe Hershberger5956ded2012-05-15 08:59:07 +0000278 if (ethprime && strcmp(dev->name, ethprime) == 0) {
wdenkc6097192002-11-03 00:24:07 +0000279 eth_current = dev;
Joe Hershberger5956ded2012-05-15 08:59:07 +0000280 puts(" [PRIME]");
wdenkc6097192002-11-03 00:24:07 +0000281 }
282
Mike Frysinger2843ed92010-06-09 22:10:48 -0400283 if (strchr(dev->name, ' '))
Joe Hershberger5956ded2012-05-15 08:59:07 +0000284 puts("\nWarning: eth device name has a space!"
285 "\n");
Mike Frysinger2843ed92010-06-09 22:10:48 -0400286
Pavel Machek222981f2014-07-13 10:27:02 +0200287 eth_write_hwaddr(dev, "eth", dev->index);
wdenkc6097192002-11-03 00:24:07 +0000288
wdenkc6097192002-11-03 00:24:07 +0000289 dev = dev->next;
Michael Walle391da4c2011-10-27 11:31:35 +0000290 num_devices++;
Joe Hershberger5956ded2012-05-15 08:59:07 +0000291 } while (dev != eth_devices);
wdenkc6097192002-11-03 00:24:07 +0000292
Simon Glass1e9961d2011-02-16 11:14:33 -0800293 eth_current_changed();
Joe Hershberger5956ded2012-05-15 08:59:07 +0000294 putc('\n');
wdenkc6097192002-11-03 00:24:07 +0000295 }
296
Michael Walle391da4c2011-10-27 11:31:35 +0000297 return num_devices;
wdenkc6097192002-11-03 00:24:07 +0000298}
299
David Updegraff7280da72007-06-11 10:41:07 -0500300/* Multicast.
301 * mcast_addr: multicast ipaddr from which multicast Mac is made
Wolfgang Denk627f5c32007-08-14 09:47:27 +0200302 * join: 1=join, 0=leave.
David Updegraff7280da72007-06-11 10:41:07 -0500303 */
Joe Hershberger5874dec2015-04-08 01:41:01 -0500304int eth_mcast_join(struct in_addr mcast_ip, int join)
David Updegraff7280da72007-06-11 10:41:07 -0500305{
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100306 u8 mcast_mac[ARP_HLEN];
Wolfgang Denk627f5c32007-08-14 09:47:27 +0200307 if (!eth_current || !eth_current->mcast)
David Updegraff7280da72007-06-11 10:41:07 -0500308 return -1;
Joe Hershberger5874dec2015-04-08 01:41:01 -0500309 mcast_mac[5] = htonl(mcast_ip.s_addr) & 0xff;
310 mcast_mac[4] = (htonl(mcast_ip.s_addr)>>8) & 0xff;
311 mcast_mac[3] = (htonl(mcast_ip.s_addr)>>16) & 0x7f;
David Updegraff7280da72007-06-11 10:41:07 -0500312 mcast_mac[2] = 0x5e;
313 mcast_mac[1] = 0x0;
314 mcast_mac[0] = 0x1;
315 return eth_current->mcast(eth_current, mcast_mac, join);
316}
317
Joe Hershberger3dbe17e2015-03-22 17:09:06 -0500318int eth_init(void)
wdenkc6097192002-11-03 00:24:07 +0000319{
Joe Hershberger7e0b0152015-05-20 14:27:26 -0500320 struct eth_device *old_current;
wdenkc6097192002-11-03 00:24:07 +0000321
Stefan Roese11da2be2008-03-04 17:40:41 +0100322 if (!eth_current) {
Heinrich Schuchardt653f3ee2020-09-14 11:00:18 +0200323 log_err("No ethernet found.\n");
Joe Hershbergerd0ce3412015-03-22 17:09:04 -0500324 return -ENODEV;
Stefan Roese11da2be2008-03-04 17:40:41 +0100325 }
wdenkc6097192002-11-03 00:24:07 +0000326
327 old_current = eth_current;
328 do {
Robin Getz9e0a4d62009-07-23 03:01:03 -0400329 debug("Trying %s\n", eth_current->name);
wdenkc6097192002-11-03 00:24:07 +0000330
Joe Hershberger3dbe17e2015-03-22 17:09:06 -0500331 if (eth_current->init(eth_current, gd->bd) >= 0) {
wdenkc6097192002-11-03 00:24:07 +0000332 eth_current->state = ETH_STATE_ACTIVE;
333
Upakul Barkakatyaed33582007-11-29 12:16:13 +0530334 return 0;
wdenkc6097192002-11-03 00:24:07 +0000335 }
Robin Getz9e0a4d62009-07-23 03:01:03 -0400336 debug("FAIL\n");
wdenkc6097192002-11-03 00:24:07 +0000337
338 eth_try_another(0);
339 } while (old_current != eth_current);
340
Joe Hershbergerd0ce3412015-03-22 17:09:04 -0500341 return -ETIMEDOUT;
wdenkc6097192002-11-03 00:24:07 +0000342}
343
344void eth_halt(void)
345{
346 if (!eth_current)
347 return;
348
349 eth_current->halt(eth_current);
350
351 eth_current->state = ETH_STATE_PASSIVE;
352}
353
Bernhard Nortmann8de9d122015-09-14 15:29:43 +0200354int eth_is_active(struct eth_device *dev)
355{
356 return dev && dev->state == ETH_STATE_ACTIVE;
357}
358
Joe Hershberger4b7747e2012-05-15 08:59:04 +0000359int eth_send(void *packet, int length)
wdenkc6097192002-11-03 00:24:07 +0000360{
Ramon Friedac598c12019-07-18 21:43:30 +0300361 int ret;
362
wdenkc6097192002-11-03 00:24:07 +0000363 if (!eth_current)
Joe Hershbergerd0ce3412015-03-22 17:09:04 -0500364 return -ENODEV;
wdenkc6097192002-11-03 00:24:07 +0000365
Ramon Friedac598c12019-07-18 21:43:30 +0300366 ret = eth_current->send(eth_current, packet, length);
367#if defined(CONFIG_CMD_PCAP)
368 if (ret >= 0)
Jorge Ramirez-Ortiz50511fc2020-12-04 20:59:58 +0100369 pcap_post(packet, length, true);
Ramon Friedac598c12019-07-18 21:43:30 +0300370#endif
371 return ret;
wdenkc6097192002-11-03 00:24:07 +0000372}
373
374int eth_rx(void)
375{
376 if (!eth_current)
Joe Hershbergerd0ce3412015-03-22 17:09:04 -0500377 return -ENODEV;
wdenkc6097192002-11-03 00:24:07 +0000378
379 return eth_current->recv(eth_current);
380}
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +0100381
382#ifdef CONFIG_API
Joe Hershberger4b7747e2012-05-15 08:59:04 +0000383static void eth_save_packet(void *packet, int length)
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +0100384{
Joe Hershberger4b7747e2012-05-15 08:59:04 +0000385 char *p = packet;
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +0100386 int i;
387
388 if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current)
389 return;
390
391 if (PKTSIZE < length)
392 return;
393
394 for (i = 0; i < length; i++)
395 eth_rcv_bufs[eth_rcv_last].data[i] = p[i];
396
397 eth_rcv_bufs[eth_rcv_last].length = length;
398 eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX;
399}
400
Joe Hershberger4b7747e2012-05-15 08:59:04 +0000401int eth_receive(void *packet, int length)
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +0100402{
Joe Hershberger4b7747e2012-05-15 08:59:04 +0000403 char *p = packet;
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +0100404 void *pp = push_packet;
405 int i;
406
407 if (eth_rcv_current == eth_rcv_last) {
408 push_packet = eth_save_packet;
409 eth_rx();
410 push_packet = pp;
411
412 if (eth_rcv_current == eth_rcv_last)
413 return -1;
414 }
415
Michael Walledf7c98a2012-06-22 11:24:28 +0000416 length = min(eth_rcv_bufs[eth_rcv_current].length, length);
Rafal Jaworowski1f2c9a42007-12-27 18:19:02 +0100417
418 for (i = 0; i < length; i++)
419 p[i] = eth_rcv_bufs[eth_rcv_current].data[i];
420
421 eth_rcv_current = (eth_rcv_current + 1) % PKTBUFSRX;
422 return length;
423}
424#endif /* CONFIG_API */