blob: 0b282d918bec382d2aae28f8b396249cf9c2553c [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00002/*
Joe Hershberger05c3e682015-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 Hershberger05c3e682015-03-22 17:09:10 -05005 * Joe Hershberger, National Instruments
wdenkc6097192002-11-03 00:24:07 +00006 */
7
8#include <common.h>
Simon Glass52f24232020-05-10 11:40:00 -06009#include <bootstage.h>
wdenkc6097192002-11-03 00:24:07 +000010#include <command.h>
Simon Glass2a64ada2020-07-19 10:15:39 -060011#include <dm.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060012#include <env.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060013#include <log.h>
wdenkc6097192002-11-03 00:24:07 +000014#include <net.h>
Andy Fleming5f184712011-04-08 02:10:27 -050015#include <phy.h>
Simon Glass401d1c42020-10-30 21:38:53 -060016#include <asm/global_data.h>
Simon Glasseb41d8a2020-05-10 11:40:08 -060017#include <linux/bug.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090018#include <linux/errno.h>
Ramon Fried3eaac632019-07-18 21:43:30 +030019#include <net/pcap.h>
Simon Glass818f91e2016-01-17 14:51:57 -070020#include "eth_internal.h"
wdenkc6097192002-11-03 00:24:07 +000021
Joe Hershbergerd2eaec62015-03-22 17:09:06 -050022DECLARE_GLOBAL_DATA_PTR;
23
Simon Glass3bc42702015-04-05 16:07:37 -060024/*
25 * CPU and board-specific Ethernet initializations. Aliased function
26 * signals caller to move on
27 */
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +090028static int __def_eth_init(struct bd_info *bis)
Simon Glass3bc42702015-04-05 16:07:37 -060029{
30 return -1;
31}
Masahiro Yamadab75d8dc2020-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 Glass3bc42702015-04-05 16:07:37 -060034
Rafal Jaworowskif85b6072007-12-27 18:19:02 +010035#ifdef CONFIG_API
Rafal Jaworowskif85b6072007-12-27 18:19:02 +010036static struct {
37 uchar data[PKTSIZE];
38 int length;
39} eth_rcv_bufs[PKTBUFSRX];
40
Joe Hershberger66c73852012-05-15 08:59:07 +000041static unsigned int eth_rcv_current, eth_rcv_last;
Rafal Jaworowskif85b6072007-12-27 18:19:02 +010042#endif
43
Joe Hershbergerf8be7d62012-08-03 10:59:08 +000044static struct eth_device *eth_devices;
45struct eth_device *eth_current;
wdenkc6097192002-11-03 00:24:07 +000046
Simon Glass8607a6b2016-01-17 14:51:59 -070047void eth_set_current_to_next(void)
Joe Hershberger84eb1fb2015-03-22 17:09:03 -050048{
49 eth_current = eth_current->next;
50}
51
Simon Glass8607a6b2016-01-17 14:51:59 -070052void eth_set_dev(struct eth_device *dev)
Joe Hershbergere58780d2015-03-22 17:09:16 -050053{
54 eth_current = dev;
55}
56
Ben Warrend7fb9bc2010-07-29 12:56:11 -070057struct eth_device *eth_get_dev_by_name(const char *devname)
Marian Balakowicz63ff0042005-10-28 22:30:33 +020058{
59 struct eth_device *dev, *target_dev;
60
Helmut Raiger7e7f9032011-08-22 00:17:17 +000061 BUG_ON(devname == NULL);
62
Marian Balakowicz63ff0042005-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 Fleming9e569862009-02-11 15:07:24 -060079struct eth_device *eth_get_dev_by_index(int index)
80{
81 struct eth_device *dev, *target_dev;
Andy Fleming9e569862009-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 Wallefea7dca2011-10-27 11:31:35 +000089 if (dev->index == index) {
Andy Fleming9e569862009-02-11 15:07:24 -060090 target_dev = dev;
91 break;
92 }
93 dev = dev->next;
Andy Fleming9e569862009-02-11 15:07:24 -060094 } while (dev != eth_devices);
95
96 return target_dev;
97}
98
Joe Hershberger66c73852012-05-15 08:59:07 +000099int eth_get_dev_index(void)
wdenkc6097192002-11-03 00:24:07 +0000100{
Joe Hershberger66c73852012-05-15 08:59:07 +0000101 if (!eth_current)
Michael Wallefea7dca2011-10-27 11:31:35 +0000102 return -1;
wdenkc6097192002-11-03 00:24:07 +0000103
Michael Wallefea7dca2011-10-27 11:31:35 +0000104 return eth_current->index;
wdenkc6097192002-11-03 00:24:07 +0000105}
106
Joe Hershberger6e0d26c2015-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 Glass0b1284e2021-07-24 09:03:30 -0600117 index = dectoul(name + 3, NULL);
Joe Hershberger6e0d26c2015-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 Hershbergerfb8977c2019-09-13 19:21:16 -0500125 string_to_enetaddr(value, dev->enetaddr);
Marek Vasut73d570a72016-11-12 16:28:40 +0100126 eth_write_hwaddr(dev, "eth", dev->index);
Joe Hershberger6e0d26c2015-05-20 14:27:26 -0500127 break;
128 case env_op_delete:
oliver@schinagl.nla40db6d2016-11-25 16:30:19 +0100129 memset(dev->enetaddr, 0, ARP_HLEN);
Joe Hershberger6e0d26c2015-05-20 14:27:26 -0500130 }
131 }
Gong Qianyu7aba0f22015-08-31 11:34:43 +0800132 dev = dev->next;
Joe Hershberger6e0d26c2015-05-20 14:27:26 -0500133 } while (dev != eth_devices);
134
135 return 0;
136}
137U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);
138
Simon Glass7616e782011-06-13 16:13:10 -0700139int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
140 int eth_number)
141{
oliver@schinagl.nla40db6d2016-11-25 16:30:19 +0100142 unsigned char env_enetaddr[ARP_HLEN];
Simon Glass7616e782011-06-13 16:13:10 -0700143 int ret = 0;
144
Simon Glass35affd72017-08-03 12:22:14 -0600145 eth_env_get_enetaddr_by_index(base_name, eth_number, env_enetaddr);
Simon Glass7616e782011-06-13 16:13:10 -0700146
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500147 if (!is_zero_ethaddr(env_enetaddr)) {
148 if (!is_zero_ethaddr(dev->enetaddr) &&
oliver@schinagl.nla40db6d2016-11-25 16:30:19 +0100149 memcmp(dev->enetaddr, env_enetaddr, ARP_HLEN)) {
Simon Glass7616e782011-06-13 16:13:10 -0700150 printf("\nWarning: %s MAC addresses don't match:\n",
Joe Hershbergerff819a32015-04-08 01:41:19 -0500151 dev->name);
Simon Glass7616e782011-06-13 16:13:10 -0700152 printf("Address in SROM is %pM\n",
Joe Hershbergerff819a32015-04-08 01:41:19 -0500153 dev->enetaddr);
Simon Glass7616e782011-06-13 16:13:10 -0700154 printf("Address in environment is %pM\n",
Joe Hershbergerff819a32015-04-08 01:41:19 -0500155 env_enetaddr);
Simon Glass7616e782011-06-13 16:13:10 -0700156 }
157
oliver@schinagl.nla40db6d2016-11-25 16:30:19 +0100158 memcpy(dev->enetaddr, env_enetaddr, ARP_HLEN);
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500159 } else if (is_valid_ethaddr(dev->enetaddr)) {
Simon Glassfd1e9592017-08-03 12:22:11 -0600160 eth_env_set_enetaddr_by_index(base_name, eth_number,
161 dev->enetaddr);
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500162 } else if (is_zero_ethaddr(dev->enetaddr)) {
Joe Hershbergerbef10142015-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);
Michal Simek381e6e52022-01-11 10:28:09 +0100167 eth_env_set_enetaddr_by_index("eth", eth_number,
168 dev->enetaddr);
Joe Hershbergerbef10142015-05-04 14:55:13 -0500169#else
Pavel Machek75d9a452014-07-13 10:27:02 +0200170 printf("\nError: %s address not set.\n",
171 dev->name);
172 return -EINVAL;
Joe Hershbergerbef10142015-05-04 14:55:13 -0500173#endif
Simon Glass7616e782011-06-13 16:13:10 -0700174 }
175
Pavel Machek75d9a452014-07-13 10:27:02 +0200176 if (dev->write_hwaddr && !eth_mac_skip(eth_number)) {
Joe Hershberger0adb5b72015-04-08 01:41:04 -0500177 if (!is_valid_ethaddr(dev->enetaddr)) {
Pavel Machek75d9a452014-07-13 10:27:02 +0200178 printf("\nError: %s address %pM illegal value\n",
Joe Hershbergerff819a32015-04-08 01:41:19 -0500179 dev->name, dev->enetaddr);
Pavel Machek75d9a452014-07-13 10:27:02 +0200180 return -EINVAL;
181 }
Benoît Thébaudeau460f9492012-08-10 07:56:21 +0000182
Simon Glass7616e782011-06-13 16:13:10 -0700183 ret = dev->write_hwaddr(dev);
Pavel Machek75d9a452014-07-13 10:27:02 +0200184 if (ret)
Joe Hershbergerff819a32015-04-08 01:41:19 -0500185 printf("\nWarning: %s failed to set MAC address\n",
186 dev->name);
Benoît Thébaudeau460f9492012-08-10 07:56:21 +0000187 }
Simon Glass7616e782011-06-13 16:13:10 -0700188
189 return ret;
190}
191
Simon Glass89d48362011-02-16 11:14:33 -0800192int eth_register(struct eth_device *dev)
193{
194 struct eth_device *d;
Joe Hershberger66c73852012-05-15 08:59:07 +0000195 static int index;
Michal Simek58c583b2011-08-29 23:30:13 +0000196
Mike Frysingerf6add132011-11-10 14:11:04 +0000197 assert(strlen(dev->name) < sizeof(dev->name));
Michal Simek58c583b2011-08-29 23:30:13 +0000198
Simon Glass89d48362011-02-16 11:14:33 -0800199 if (!eth_devices) {
Joe Hershbergerff819a32015-04-08 01:41:19 -0500200 eth_devices = dev;
201 eth_current = dev;
Simon Glass89d48362011-02-16 11:14:33 -0800202 eth_current_changed();
wdenkc6097192002-11-03 00:24:07 +0000203 } else {
Joe Hershberger66c73852012-05-15 08:59:07 +0000204 for (d = eth_devices; d->next != eth_devices; d = d->next)
Detlev Zundelaba4b692010-03-31 17:56:08 +0200205 ;
wdenkc6097192002-11-03 00:24:07 +0000206 d->next = dev;
207 }
208
209 dev->state = ETH_STATE_INIT;
210 dev->next = eth_devices;
Michael Wallefea7dca2011-10-27 11:31:35 +0000211 dev->index = index++;
wdenkc6097192002-11-03 00:24:07 +0000212
213 return 0;
214}
215
Vincent Palatine7e982d2012-01-09 08:32:36 +0000216int eth_unregister(struct eth_device *dev)
217{
218 struct eth_device *cur;
219
220 /* No device */
221 if (!eth_devices)
Joe Hershberger05324a42015-03-22 17:09:04 -0500222 return -ENODEV;
Vincent Palatine7e982d2012-01-09 08:32:36 +0000223
224 for (cur = eth_devices; cur->next != eth_devices && cur->next != dev;
225 cur = cur->next)
226 ;
227
228 /* Device not found */
229 if (cur->next != dev)
Joe Hershberger05324a42015-03-22 17:09:04 -0500230 return -ENODEV;
Vincent Palatine7e982d2012-01-09 08:32:36 +0000231
232 cur->next = dev->next;
233
234 if (eth_devices == dev)
235 eth_devices = dev->next == eth_devices ? NULL : dev->next;
236
237 if (eth_current == dev) {
238 eth_current = eth_devices;
239 eth_current_changed();
240 }
241
242 return 0;
243}
244
Joe Hershbergerd2eaec62015-03-22 17:09:06 -0500245int eth_initialize(void)
wdenkc6097192002-11-03 00:24:07 +0000246{
Michael Wallefea7dca2011-10-27 11:31:35 +0000247 int num_devices = 0;
Simon Glass3bc42702015-04-05 16:07:37 -0600248
wdenkc6097192002-11-03 00:24:07 +0000249 eth_devices = NULL;
250 eth_current = NULL;
Simon Glass3bc42702015-04-05 16:07:37 -0600251 eth_common_init();
Simon Glass818f91e2016-01-17 14:51:57 -0700252 /*
253 * If board-specific initialization exists, call it.
254 * If not, call a CPU-specific one
255 */
256 if (board_eth_init != __def_eth_init) {
257 if (board_eth_init(gd->bd) < 0)
258 printf("Board Net Initialization Failed\n");
259 } else if (cpu_eth_init != __def_eth_init) {
260 if (cpu_eth_init(gd->bd) < 0)
261 printf("CPU Net Initialization Failed\n");
262 } else {
263 printf("Net Initialization Skipped\n");
264 }
Marian Balakowiczd9785c12005-11-30 18:06:04 +0100265
wdenkc6097192002-11-03 00:24:07 +0000266 if (!eth_devices) {
Heinrich Schuchardtad895912020-09-14 11:00:18 +0200267 log_err("No ethernet found.\n");
Simon Glass770605e2012-02-13 13:51:18 +0000268 bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
wdenkc6097192002-11-03 00:24:07 +0000269 } else {
270 struct eth_device *dev = eth_devices;
Simon Glass00caae62017-08-03 12:22:12 -0600271 char *ethprime = env_get("ethprime");
wdenkc6097192002-11-03 00:24:07 +0000272
Simon Glass770605e2012-02-13 13:51:18 +0000273 bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
wdenkc6097192002-11-03 00:24:07 +0000274 do {
Michael Wallefea7dca2011-10-27 11:31:35 +0000275 if (dev->index)
Joe Hershberger66c73852012-05-15 08:59:07 +0000276 puts(", ");
wdenkc6097192002-11-03 00:24:07 +0000277
278 printf("%s", dev->name);
279
Joe Hershberger66c73852012-05-15 08:59:07 +0000280 if (ethprime && strcmp(dev->name, ethprime) == 0) {
wdenkc6097192002-11-03 00:24:07 +0000281 eth_current = dev;
Joe Hershberger66c73852012-05-15 08:59:07 +0000282 puts(" [PRIME]");
wdenkc6097192002-11-03 00:24:07 +0000283 }
284
Mike Frysinger1384f3b2010-06-09 22:10:48 -0400285 if (strchr(dev->name, ' '))
Joe Hershberger66c73852012-05-15 08:59:07 +0000286 puts("\nWarning: eth device name has a space!"
287 "\n");
Mike Frysinger1384f3b2010-06-09 22:10:48 -0400288
Pavel Machek75d9a452014-07-13 10:27:02 +0200289 eth_write_hwaddr(dev, "eth", dev->index);
wdenkc6097192002-11-03 00:24:07 +0000290
wdenkc6097192002-11-03 00:24:07 +0000291 dev = dev->next;
Michael Wallefea7dca2011-10-27 11:31:35 +0000292 num_devices++;
Joe Hershberger66c73852012-05-15 08:59:07 +0000293 } while (dev != eth_devices);
wdenkc6097192002-11-03 00:24:07 +0000294
Simon Glass89d48362011-02-16 11:14:33 -0800295 eth_current_changed();
Joe Hershberger66c73852012-05-15 08:59:07 +0000296 putc('\n');
wdenkc6097192002-11-03 00:24:07 +0000297 }
298
Michael Wallefea7dca2011-10-27 11:31:35 +0000299 return num_devices;
wdenkc6097192002-11-03 00:24:07 +0000300}
301
David Updegraff53a5c422007-06-11 10:41:07 -0500302/* Multicast.
303 * mcast_addr: multicast ipaddr from which multicast Mac is made
Wolfgang Denk85eb5ca2007-08-14 09:47:27 +0200304 * join: 1=join, 0=leave.
David Updegraff53a5c422007-06-11 10:41:07 -0500305 */
Joe Hershberger049a95a2015-04-08 01:41:01 -0500306int eth_mcast_join(struct in_addr mcast_ip, int join)
David Updegraff53a5c422007-06-11 10:41:07 -0500307{
oliver@schinagl.nla40db6d2016-11-25 16:30:19 +0100308 u8 mcast_mac[ARP_HLEN];
Wolfgang Denk85eb5ca2007-08-14 09:47:27 +0200309 if (!eth_current || !eth_current->mcast)
David Updegraff53a5c422007-06-11 10:41:07 -0500310 return -1;
Joe Hershberger049a95a2015-04-08 01:41:01 -0500311 mcast_mac[5] = htonl(mcast_ip.s_addr) & 0xff;
312 mcast_mac[4] = (htonl(mcast_ip.s_addr)>>8) & 0xff;
313 mcast_mac[3] = (htonl(mcast_ip.s_addr)>>16) & 0x7f;
David Updegraff53a5c422007-06-11 10:41:07 -0500314 mcast_mac[2] = 0x5e;
315 mcast_mac[1] = 0x0;
316 mcast_mac[0] = 0x1;
317 return eth_current->mcast(eth_current, mcast_mac, join);
318}
319
Joe Hershbergerd2eaec62015-03-22 17:09:06 -0500320int eth_init(void)
wdenkc6097192002-11-03 00:24:07 +0000321{
Joe Hershberger6e0d26c2015-05-20 14:27:26 -0500322 struct eth_device *old_current;
wdenkc6097192002-11-03 00:24:07 +0000323
Stefan Roese6bc11382008-03-04 17:40:41 +0100324 if (!eth_current) {
Heinrich Schuchardtad895912020-09-14 11:00:18 +0200325 log_err("No ethernet found.\n");
Joe Hershberger05324a42015-03-22 17:09:04 -0500326 return -ENODEV;
Stefan Roese6bc11382008-03-04 17:40:41 +0100327 }
wdenkc6097192002-11-03 00:24:07 +0000328
329 old_current = eth_current;
330 do {
Robin Getz0ebf04c2009-07-23 03:01:03 -0400331 debug("Trying %s\n", eth_current->name);
wdenkc6097192002-11-03 00:24:07 +0000332
Joe Hershbergerd2eaec62015-03-22 17:09:06 -0500333 if (eth_current->init(eth_current, gd->bd) >= 0) {
wdenkc6097192002-11-03 00:24:07 +0000334 eth_current->state = ETH_STATE_ACTIVE;
335
Upakul Barkakaty505be872007-11-29 12:16:13 +0530336 return 0;
wdenkc6097192002-11-03 00:24:07 +0000337 }
Robin Getz0ebf04c2009-07-23 03:01:03 -0400338 debug("FAIL\n");
wdenkc6097192002-11-03 00:24:07 +0000339
340 eth_try_another(0);
341 } while (old_current != eth_current);
342
Joe Hershberger05324a42015-03-22 17:09:04 -0500343 return -ETIMEDOUT;
wdenkc6097192002-11-03 00:24:07 +0000344}
345
346void eth_halt(void)
347{
348 if (!eth_current)
349 return;
350
351 eth_current->halt(eth_current);
352
353 eth_current->state = ETH_STATE_PASSIVE;
354}
355
Bernhard Nortmanneaa8a192015-09-14 15:29:43 +0200356int eth_is_active(struct eth_device *dev)
357{
358 return dev && dev->state == ETH_STATE_ACTIVE;
359}
360
Joe Hershbergerdb288a92012-05-15 08:59:04 +0000361int eth_send(void *packet, int length)
wdenkc6097192002-11-03 00:24:07 +0000362{
Ramon Fried3eaac632019-07-18 21:43:30 +0300363 int ret;
364
wdenkc6097192002-11-03 00:24:07 +0000365 if (!eth_current)
Joe Hershberger05324a42015-03-22 17:09:04 -0500366 return -ENODEV;
wdenkc6097192002-11-03 00:24:07 +0000367
Ramon Fried3eaac632019-07-18 21:43:30 +0300368 ret = eth_current->send(eth_current, packet, length);
369#if defined(CONFIG_CMD_PCAP)
370 if (ret >= 0)
Jorge Ramirez-Ortizc1ab7382020-12-04 20:59:58 +0100371 pcap_post(packet, length, true);
Ramon Fried3eaac632019-07-18 21:43:30 +0300372#endif
373 return ret;
wdenkc6097192002-11-03 00:24:07 +0000374}
375
376int eth_rx(void)
377{
378 if (!eth_current)
Joe Hershberger05324a42015-03-22 17:09:04 -0500379 return -ENODEV;
wdenkc6097192002-11-03 00:24:07 +0000380
381 return eth_current->recv(eth_current);
382}
383
Rafal Jaworowskif85b6072007-12-27 18:19:02 +0100384#ifdef CONFIG_API
Joe Hershbergerdb288a92012-05-15 08:59:04 +0000385static void eth_save_packet(void *packet, int length)
Rafal Jaworowskif85b6072007-12-27 18:19:02 +0100386{
Joe Hershbergerdb288a92012-05-15 08:59:04 +0000387 char *p = packet;
Rafal Jaworowskif85b6072007-12-27 18:19:02 +0100388 int i;
389
390 if ((eth_rcv_last+1) % PKTBUFSRX == eth_rcv_current)
391 return;
392
393 if (PKTSIZE < length)
394 return;
395
396 for (i = 0; i < length; i++)
397 eth_rcv_bufs[eth_rcv_last].data[i] = p[i];
398
399 eth_rcv_bufs[eth_rcv_last].length = length;
400 eth_rcv_last = (eth_rcv_last + 1) % PKTBUFSRX;
401}
402
Joe Hershbergerdb288a92012-05-15 08:59:04 +0000403int eth_receive(void *packet, int length)
Rafal Jaworowskif85b6072007-12-27 18:19:02 +0100404{
Joe Hershbergerdb288a92012-05-15 08:59:04 +0000405 char *p = packet;
Rafal Jaworowskif85b6072007-12-27 18:19:02 +0100406 void *pp = push_packet;
407 int i;
408
409 if (eth_rcv_current == eth_rcv_last) {
410 push_packet = eth_save_packet;
411 eth_rx();
412 push_packet = pp;
413
414 if (eth_rcv_current == eth_rcv_last)
415 return -1;
416 }
417
Michael Walle46c07bc2012-06-22 11:24:28 +0000418 length = min(eth_rcv_bufs[eth_rcv_current].length, length);
Rafal Jaworowskif85b6072007-12-27 18:19:02 +0100419
420 for (i = 0; i < length; i++)
421 p[i] = eth_rcv_bufs[eth_rcv_current].data[i];
422
423 eth_rcv_current = (eth_rcv_current + 1) % PKTBUFSRX;
424 return length;
425}
426#endif /* CONFIG_API */