Changeset 07ed2f87 in rtems for c/src/lib


Ignore:
Timestamp:
Aug 17, 2009, 2:25:28 PM (11 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 5, master
Children:
58dbfd7
Parents:
e0d71f7
Message:

2009-08-17 Till Straumann <strauman@…>

  • network/tsec.c, network/if_tsec_pub.h: Fixed bugs in multicast support; added reference-count for hash-table entries which allows for the implementation of a 'deletion' routine. NOTE: mcast support largely untested.
Location:
c/src/lib/libbsp/powerpc/mvme3100
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/mvme3100/ChangeLog

    re0d71f7 r07ed2f87  
     12009-08-17      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * network/tsec.c, network/if_tsec_pub.h:
     4        Fixed bugs in multicast support; added reference-count
     5        for hash-table entries which allows for the implementation
     6        of a 'deletion' routine.
     7        NOTE: mcast support largely untested.
     8
    192009-07-16      Joel Sherrill <joel.sherrill@oarcorp.com>
    210
  • c/src/lib/libbsp/powerpc/mvme3100/network/if_tsec_pub.h

    re0d71f7 r07ed2f87  
    183183 * after executing this routine (unless the hardware was initialized
    184184 * in 'promiscuous' mode).
     185 *
     186 * Reset reference count for all hash-table entries
     187 * to zero (see BSP_tsec_mcast_filter_accept_del()).
    185188 */
    186189void
     
    189192/*
    190193 * Program multicast filter to accept all multicast frames.
     194 *
     195 * Increment reference count for all hash-table entries
     196 * by one (see BSP_tsec_mcast_filter_accept_del()).
    191197 */
    192198void
     
    194200
    195201/*
    196  * Add a MAC address to the multicast filter.
     202 * Add a MAC address to the multicast filter and increment
     203 * the reference count for the matching hash-table entry
     204 * (see BSP_tsec_mcast_filter_accept_del()).
     205 *
    197206 * Existing entries are not changed but note that
    198207 * the filter is imperfect, i.e., multiple MAC addresses
     
    200209 * filtering must still be performed.
    201210 *
    202  * NOTE: Deletion of an address is not possible. This is
    203  *       usually accomplished by a higher-level driver
    204  *       maintaining a list/database of multicast addresses
    205  *       and going through a sequence:
    206  *
    207  *         BSP_tsec_mcast_filter_clear()
    208  *         forall mcast addresses do
    209  *            BSP_tsec_mcast_filter_accept_add()
    210211 */
    211212void
    212213BSP_tsec_mcast_filter_accept_add(struct tsec_private *mp, unsigned char *enaddr);
     214
     215/*
     216 * Remove a MAC address from the (imperfec) multicast
     217 * filter.
     218 * Note that the driver maintains an internal reference
     219 * counter for each multicast hash. The hash-table
     220 * entry is only cleared when the reference count
     221 * reaches zero ('del' has been called the same
     222 * amount of times as 'add' for an address (or
     223 * any alias) that matches a given table entry.
     224 * BSP_tsec_mcast_filter_clear() resets all reference
     225 * counters to zero.
     226 */
     227void
     228BSP_tsec_mcast_filter_accept_del(struct tsec_private *mp, unsigned char *enaddr);
    213229
    214230/*
  • c/src/lib/libbsp/powerpc/mvme3100/network/tsec.c

    re0d71f7 r07ed2f87  
    641641/* Driver 'private' data */
    642642
     643#define NUM_MC_HASHES           256
     644
    643645struct tsec_private {
    644646        FEC_Enet_Base   base;            /* Controller base address                  */
     
    685687                unsigned        repack;
    686688        }               stats;
     689        uint16_t                mc_refcnt[NUM_MC_HASHES];
    687690};
    688691
     
    14031406
    14041407static uint8_t
    1405 hash_accept(struct tsec_private *mp, uint32_t tble, const uint8_t *enaddr)
    1406 {
    1407 uint8_t s;
     1408hash_prog(struct tsec_private *mp, uint32_t tble, const uint8_t *enaddr, int accept)
     1409{
     1410uint8_t  s;
     1411uint32_t reg, bit;
    14081412
    14091413        s = ether_crc32_le(enaddr, ETHER_ADDR_LEN);
     
    14141418    s = ((s&0x55) << 1) | ((s&0xaa) >> 1);
    14151419
    1416         fec_wr( mp->base, tble + (s >> (5-2)), (1 << (31 - (s & 31))) );
     1420        reg = tble + ((s >> (5-2)) & ~3);
     1421        bit = 1 << (31 - (s & 31));
     1422
     1423        if ( accept ) {
     1424                if ( 0 == mp->mc_refcnt[s]++ )
     1425                        fec_set( mp->base, reg, bit );
     1426        } else {
     1427                if ( mp->mc_refcnt[s] > 0 && 0 == --mp->mc_refcnt[s] )
     1428                        fec_clr( mp->base, reg, bit );
     1429        }
    14171430}
    14181431
     
    14241437                fec_wr( mp->base, TSEC_GADDR0 + i, 0 );
    14251438        }
     1439        for ( i=0; i<NUM_MC_HASHES; i++ )
     1440                mp->mc_refcnt[i] = 0;
    14261441}
    14271442
     
    14331448                fec_wr( mp->base, TSEC_GADDR0 + i, 0xffffffff );
    14341449        }
    1435 }
    1436 
    1437 void
    1438 BSP_tsec_mcast_filter_accept_add(struct tsec_private *mp, uint8_t *enaddr)
     1450        for ( i=0; i<NUM_MC_HASHES; i++ )
     1451                mp->mc_refcnt[i]++;
     1452}
     1453
     1454static void
     1455mcast_filter_prog(struct tsec_private *mp, uint8_t *enaddr, int accept)
    14391456{
    14401457static const uint8_t bcst={0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
     
    14471464                return;
    14481465        }
    1449         hash_accept(mp, TSEC_GADDR0, enaddr);
     1466        hash_prog(mp, TSEC_GADDR0, enaddr, accept);
     1467}
     1468
     1469void
     1470BSP_tsec_mcast_filter_accept_add(struct tsec_private *mp, uint8_t *enaddr)
     1471{
     1472        mcast_filter_prog(mp, enaddr, 1 /* accept */);
     1473}
     1474
     1475void
     1476BSP_tsec_mcast_filter_accept_del(struct tsec_private *mp, uint8_t *enaddr)
     1477{
     1478        mcast_filter_prog(mp, enaddr, 0 /* delete */);
    14501479}
    14511480
Note: See TracChangeset for help on using the changeset viewer.