source: rtems/c/src/libchip/network/dwmac-desc-com.c @ 602e395

4.115
Last change on this file since 602e395 was 4953b724, checked in by Ralf Kirchner <ralf.kirchner@…>, on 02/17/14 at 14:43:53

libchip: Add dwmac 10/100/1000 network driver

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief  DWMAC 10/100/1000 Common Descriptor Handling
5 *
6 * DWMAC 10/100/1000 on-chip Ethernet controllers.
7 * Functions which are common to normal and enhanced DMA descriptors.
8 */
9
10/*
11 * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
12 *
13 *  embedded brains GmbH
14 *  Dornierstr. 4
15 *  82178 Puchheim
16 *  Germany
17 *  <rtems@embedded-brains.de>
18 *
19 * The license and distribution terms for this file may be
20 * found in the file LICENSE in this distribution or at
21 * http://www.rtems.org/license/LICENSE.
22 */
23
24#include "dwmac-desc-com.h"
25
26#undef DWMAC_DESC_COM_DEBUG
27#ifdef DWMAC_DESC_COM_DEBUG
28#define DWMAC_DESC_COM_PRINT_DBG( fmt, args ... )  printk( fmt, ## args )
29#else
30#define DWMAC_DESC_COM_PRINT_DBG( fmt, args ... )  do { } while ( 0 )
31#endif
32
33struct mbuf *dwmac_desc_com_new_mbuf( dwmac_common_context *self ) {
34  struct  ifnet *ifp = &self->arpcom.ac_if;
35  struct  mbuf  *m   = NULL;
36
37
38  MGETHDR( m, M_DONTWAIT, MT_DATA );
39
40  if ( m != NULL ) {
41    MCLGET( m, M_DONTWAIT );
42
43    if ( m->m_ext.ext_buf != NULL ) {
44      if ( ( m->m_flags & M_EXT ) != 0 ) {
45        /* Set receive interface */
46        m->m_pkthdr.rcvif = ifp;
47
48        /* Make sure packet data will be aligned */
49        m->m_data = mtod( m, char * ) + ETHER_ALIGN;
50        return m;
51      } else {
52        m_free( m );
53      }
54    } else {
55      m_free( m );
56    }
57  }
58
59  return NULL;
60}
Note: See TracBrowser for help on using the repository browser.