Commit a77af289 authored by ROOL's avatar ROOL 🤖

Import of EtherCPSW

parents
|
| Copyright (c) 2014, Elesar Ltd
| All rights reserved.
|
| Redistribution and use in source and binary forms, with or without
| modification, are permitted provided that the following conditions are met:
| * Redistributions of source code must retain the above copyright
| notice, this list of conditions and the following disclaimer.
| * Redistributions in binary form must reproduce the above copyright
| notice, this list of conditions and the following disclaimer in the
| documentation and/or other materials provided with the distribution.
| * Neither the name of Elesar Ltd nor the names of its contributors
| may be used to endorse or promote products derived from this software
| without specific prior written permission.
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
| POSSIBILITY OF SUCH DAMAGE.
|
Dir <Obey$Dir>
amu_machine clean
stripdepnd
|
| Copyright (c) 2014, Elesar Ltd
| All rights reserved.
|
| Redistribution and use in source and binary forms, with or without
| modification, are permitted provided that the following conditions are met:
| * Redistributions of source code must retain the above copyright
| notice, this list of conditions and the following disclaimer.
| * Redistributions in binary form must reproduce the above copyright
| notice, this list of conditions and the following disclaimer in the
| documentation and/or other materials provided with the distribution.
| * Neither the name of Elesar Ltd nor the names of its contributors
| may be used to endorse or promote products derived from this software
| without specific prior written permission.
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
| POSSIBILITY OF SUCH DAMAGE.
|
Dir <Obey$Dir>
amu_machine debug THROWBACK=-throwback
|
| Copyright (c) 2014, Elesar Ltd
| All rights reserved.
|
| Redistribution and use in source and binary forms, with or without
| modification, are permitted provided that the following conditions are met:
| * Redistributions of source code must retain the above copyright
| notice, this list of conditions and the following disclaimer.
| * Redistributions in binary form must reproduce the above copyright
| notice, this list of conditions and the following disclaimer in the
| documentation and/or other materials provided with the distribution.
| * Neither the name of Elesar Ltd nor the names of its contributors
| may be used to endorse or promote products derived from this software
| without specific prior written permission.
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
| POSSIBILITY OF SUCH DAMAGE.
|
Dir <Obey$Dir>
amu_machine standalone THROWBACK=-throwback
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
*,ffb gitlab-language=bbcbasic linguist-language=bbcbasic linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
Copyright (c) 2012-2013, RISC OS Open Ltd
Copyright (c) 2014, Elesar Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holders nor the names of their
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 1997 Manuel Bouyer.
Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org>
Copyright (c) 2013 Jonathan A. Kollasch
All rights reserved.
This code is derived from software contributed to The NetBSD Foundation
by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
NASA Ames Research Center.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Copyright (c) 2014, Elesar Ltd
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Elesar Ltd nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Makefile for EtherCPSW
#
COMPONENT = EtherCPSW
TARGET ?= EtherCPSW
OBJS = ecpmodule if_cpsw glue filtering filteringasm
CMHGDEPENDS = ecpmodule glue
ROMCDEFINES = -DROM
RES_AREA = ethercp_messages
HDRS =
CINCLUDES = -ITCPIPLibs:,C:
LIBS += ${NET5LIBS} ${ASMUTILS}
CUSTOMSA = custom
include CModule
CFLAGS += -Wp -DRISCOS -D_KERNEL -DINET
CDFLAGS += -DDEBUG
#
# Specials for install (and standalone because they use the same override)
#
standalone: rm.${SA_TARGET}
@${ECHO} ${COMPONENT}: ram module built
install: install_${TARGET}; @
install_EtherY: rm.${SA_TARGET}
${MKDIR} ${INSTDIR}
${CP} rm.${SA_TARGET} ${INSTDIR}.${TARGET} ${CPFLAGS}
@${ECHO} ${COMPONENT}: ram module installed
install_AutoSense: AutoSense.${COMPONENT}
${CP} AutoSense.${COMPONENT} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@${ECHO} ${COMPONENT}: AutoSense file installed
# Dynamic dependencies:
#{DictTokens}
# Unix errors
E01:Operation not permitted
E05:Input/output error
E06:Invalid unit number
E12:Out of memory
E22:Invalid argument
E25:Inappropriate operation
E40:Oversized message
E50:Link is down
E55:Out of buffers
E135:Higher priority filter already claimed
# Private errors
E200:No EtherCPSW compatible interfaces found
E201:Virtual interfaces cannot be configured
E202:Interface has no hardware address
E203:Multiple instantiation forbidden
E204:Failed to detect CPSW controller
E205:Interface not active on this driver
# Messages
M00:Length--------------
M01:Interface driver
M02:Interface unit
M03:Interface location
M04:Interface EUI48
M05:Interface controller
M06:Running time
#M07:
#M08:
M09:%dd, %dh %dm %ds
M10:up
M11:down
M12:Motherboard
M13:Virtual
#M14:
#M15:
M16:passed
M17:failed
M18:EtherCPSW interface statistics
#M19:
M20:Packets sent
M21:Packets received
M22:Bytes sent
M23:Bytes received
M24:Send errors
M25:Receive errors
M26:Undelivered packets
M27:IEEE 802.3 clients
M28:Monitor clients
M29:Sink clients
M30:Standard clients
M31:Type %04X (AddrLvl %02X, ErrLvl %02X) handler=(%p/%p)
M32:selftest
M33:Interface media
M34:%0baseT half duplex
M35:%0baseT full duplex
M36:Unplugged
M37:unit number
This diff is collapsed.
/*
* Copyright (c) 2013, RISC OS Open Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of RISC OS Open Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "swis.h"
#include "AsmUtils/irqs.h"
#include "sys/types.h"
#include "sys/dcistructs.h"
#include "sys/errno.h"
#include "sys/mbuf.h"
#include "net/ethernet.h"
#include "filtering.h"
#include "glue.h"
#include "ecpmodule.h"
/*
* Run a single packet through the filters
*/
void filter_input(uint8_t unit, uint8_t class, RxHdr *rxhdr, struct mbuf *chain)
{
const filter_t *sink = NULL;
const filter_t *entry;
uint16_t frame = rxhdr->rx_frame_type;
bool defects = (rxhdr->rx_error_level != 0);
/* Find the best filter */
entry = nicunit[unit]->filters;
while (entry != NULL)
{
switch (GET_FRAMELEVEL(entry->type))
{
case FRMLVL_E2SINK:
sink = entry;
break;
case FRMLVL_E2MONITOR:
if ((frame > ETHERMTU) &&
IS_A_KEEPER(entry->addresslevel, class) &&
IS_GOOD_ENOUGH(entry->errorlevel, defects))
{
/* Monitor it */
DPRINTF(("Rx%c : to monitor\n", '0' + unit));
filter_to_protocol(&nicunit[unit]->dib,
chain,
entry->handler,
entry->pw);
return;
}
break;
case FRMLVL_IEEE:
if ((frame <= ETHERMTU) &&
IS_A_KEEPER(entry->addresslevel, class) &&
IS_GOOD_ENOUGH(entry->errorlevel, defects))
{
/* Raw IEEE */
DPRINTF(("Rx%c : to IEEE\n", '0' + unit));
filter_to_protocol(&nicunit[unit]->dib,
chain,
entry->handler,
entry->pw);
return;
}
break;
case FRMLVL_E2SPECIFIC:
if ((GET_FRAMETYPE(entry->type) == frame) &&
IS_A_KEEPER(entry->addresslevel, class) &&
IS_GOOD_ENOUGH(entry->errorlevel, defects))
{
/* Specific match for this frame */
DPRINTF(("Rx%c : to specific protocol\n", '0' + unit));
filter_to_protocol(&nicunit[unit]->dib,
chain,
entry->handler,
entry->pw);
return;
}
break;
}
entry = entry->next;
}
/* Unclaimed so far, if there's no sink or it's IEEE, dump it */
if ((sink == NULL) || (frame <= ETHERMTU) ||
!IS_A_KEEPER(sink->addresslevel, class) ||
!IS_GOOD_ENOUGH(sink->errorlevel, defects))
{
DPRINTF(("Rx%c : discard\n", '0' + unit));
nicunit[unit]->rx_discards++;
m_freem(chain);
return;
}
DPRINTF(("Rx%c : to sink\n", '0' + unit));
filter_to_protocol(&nicunit[unit]->dib,
chain,
sink->handler,
sink->pw);
}
/*
* Module exit unconditionally destroys the filter list
*/
void filter_destroy(uint8_t unit)
{
filter_t *entry, *copy;
entry = nicunit[unit]->filters;
while (entry != NULL)
{
copy = entry->next;
DPRINTF(("Destroy filter %X at %p\n", entry->type, (void *)entry));
free(entry);
entry = copy;
}
}
/*
* An entire protocol module has gone
*/
void filter_protocol_remove(uint8_t unit, void *pw)
{
const filter_t *entry, *remove;
/* Private words are unique to a protocol module, key off that */
entry = nicunit[unit]->filters;
while (entry != NULL)
{
remove = entry;
entry = entry->next;
if (remove->pw == pw)
{
filter_remove(unit, remove->type, remove->addresslevel, remove->errorlevel,
remove->handler, remove->pw);
}
}
}
/*
* Add a new filter if possible
*/
_kernel_oserror *filter_add(uint8_t unit, uint32_t type, uint32_t addresslevel, uint32_t errorlevel,
filter_handler_t handler, void *pw, uint32_t flags)
{
filter_t *entry;
int state;
/* Vet the arguments before even considering adding it */
switch (GET_FRAMELEVEL(type))
{
case FRMLVL_E2SINK:
case FRMLVL_E2MONITOR:
case FRMLVL_IEEE:
if (GET_FRAMETYPE(type) != 0)
{
/* Must be zero for those */
return ethercp_error_lookup((ethercp_err_t)EINVAL);
}
/* Fall through */
case FRMLVL_E2SPECIFIC:
break;
default:
return ethercp_error_lookup((ethercp_err_t)EINVAL);
}
switch (addresslevel)
{
case ADDRLVL_SPECIFIC:
case ADDRLVL_NORMAL:
case ADDRLVL_MULTICAST:
case ADDRLVL_PROMISCUOUS:
break;
default:
return ethercp_error_lookup((ethercp_err_t)EINVAL);
}
switch (errorlevel)
{
case ERRLVL_NO_ERRORS:
case ERRLVL_ERRORS:
break;
default:
return ethercp_error_lookup((ethercp_err_t)EINVAL);
}
/* Validate flags */
if (flags >= FILTER_1STRESERVED)
{
ethercp_error_lookup((ethercp_err_t)EINVAL);
}
/* If there are already filters check this isn't a duplicate */
entry = nicunit[unit]->filters;
while (entry != NULL)
{
/* Highest current level Permitted new level
* --------------------- -------------------
* Nothing (list empty) Normal/Sink/Monitor
* Normal Normal/Sink
* Sink Normal
* Monitor None
* Normal: frame level filtering
* Sink: any frames not claimed by 'normal'
* Monitor: all frames
*/
switch (GET_FRAMELEVEL(entry->type))
{
case FRMLVL_E2SPECIFIC:
/* Permit different specifics and sink */
if ((entry->type == type) ||
(GET_FRAMELEVEL(type) == FRMLVL_E2MONITOR))
{
return ethercp_error_lookup((ethercp_err_t)EFILTERGONE);
}
break;
case FRMLVL_E2SINK:
/* Permit more specifics and IEEE when sink active */
if ((GET_FRAMELEVEL(type) == FRMLVL_E2SINK) ||
(GET_FRAMELEVEL(type) == FRMLVL_E2MONITOR))
{
return ethercp_error_lookup((ethercp_err_t)EFILTERGONE);
}
break;
case FRMLVL_E2MONITOR:
/* Permit only non Ethernet II when monitoring */
if (GET_FRAMELEVEL(type) != FRMLVL_IEEE)
{
return ethercp_error_lookup((ethercp_err_t)EFILTERGONE);
}
break;
case FRMLVL_IEEE:
/* Only one IEEE at a time */
if (GET_FRAMELEVEL(type) == FRMLVL_IEEE)
{
return ethercp_error_lookup((ethercp_err_t)EFILTERGONE);
}
break;
}
entry = entry->next;
}
/* Add it and insert it at the list head */
entry = (filter_t *)malloc(sizeof(filter_t));
DPRINTF(("Malloc filter %X at %p\n", type, (void *)entry));
if (entry == NULL) return ethercp_error_lookup((ethercp_err_t)ENOMEM);
entry->type = type;
entry->errorlevel = (uint8_t)errorlevel;
entry->addresslevel = (uint8_t)addresslevel;
entry->flags = (uint8_t)flags;
entry->pw = pw;
entry->handler = handler;
/* Careful not to leave the list dangling */
state = irqs_off();
entry->next = nicunit[unit]->filters;
nicunit[unit]->filters = entry;
restore_irqs(state);
ethercp_review_levels(unit);
return NULL;
}
/*
* Remove an existing filter if possible
*/
_kernel_oserror *filter_remove(uint8_t unit, uint32_t type, uint32_t addresslevel, uint32_t errorlevel,
filter_handler_t handler, void *pw)
{
filter_t *entry, *previous;
bool removed = FALSE;
int state;
/* No need to range check type/addresslevel/errorlevel because
* they can't be in the list after filter_add() checked. Just look for
* an exact match
*/
previous = NULL;
entry = nicunit[unit]->filters;
while (entry != NULL)
{
if ((entry->type == type) && (entry->addresslevel == addresslevel) &&
(entry->errorlevel == errorlevel))
{
/* Match... */
if ((entry->handler != handler) || (entry->pw != pw))
{
/* ...but you didn't register it */
return ethercp_error_lookup((ethercp_err_t)EPERM);
}
/* Unpick from the list */
state = irqs_off();
if (previous == NULL)
{
/* Head of list being removed */
nicunit[unit]->filters = entry->next;
}
else
{
previous->next = entry->next;
}
restore_irqs(state);
removed = TRUE;
break;
}
previous = entry;
entry = entry->next;
}
if (removed)
{
/* Announce that type became free (now the list is self consistent again) */
_swix(OS_ServiceCall, _INR(0,4), &nicunit[unit]->dib,
Service_DCIFrameTypeFree,
entry->type, entry->addresslevel, entry->errorlevel);
/* Release the block */
DPRINTF(("Free filter %X at %p\n", type, (void *)entry));
free(entry);
ethercp_review_levels(unit);
return NULL;
}
return ethercp_error_lookup((ethercp_err_t)EINVAL);
}
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (c) 2014, Elesar Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Elesar Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "Global/Services.h"
#include "VersionNum"
title-string: Module_ComponentName
help-string: Module_ComponentName Module_MajorVersion_CMHG Module_MinorVersion_CMHG
date-string: Module_Date_CMHG
international-help-file:"Resources:$.Resources."Module_ComponentName".Messages"
initialisation-code: ethercp_init
finalisation-code: ethercp_final
service-call-handler: ethercp_services Service_EnumerateNetworkDrivers,
Service_DCIProtocolStatus,
Service_MbufManagerStatus,
Service_ResourceFSStarting,
Service_PreReset
swi-chunk-base-number: 0x59600
swi-handler-code: ethercp_swis
swi-decoding-table: EtherCP,
DCIVersion Inquire GetNetworkMTU SetNetworkMTU,
Transmit Filter Stats
vector-handlers: intr
generic-veneers: ethercp_driver_linked,
ethercp_heartbeat
command-keyword-table: ethercp_commands
ECPInfo(min-args:0, max-args:1,
international:,
help-text: "HECPI",
invalid-syntax: "SECPI"),
ECPTest(min-args:0, max-args:1,
international:,
help-text: "HECPT",
invalid-syntax: "SECPT"),
ECPVirtual(min-args:1, max-args:1,
configure:,
international:,
help-text: "HECPV",
invalid-syntax: "SECPV"),
ECPLink(min-args:2, max-args:4,
configure:,
international:,
help-text: "HECPL",
invalid-syntax: "SECPL"),
ECPAdvertise(min-args:2, max-args:8,
configure:,
international:,