Skip to content

Commit 0cb20d7

Browse files
author
Peter Enderborg
committed
Add MaxLinear GSW1xx DSA driver support
For reading the packets in raw gsw1xx format.
1 parent 1f2e3d1 commit 0cb20d7

File tree

10 files changed

+215
-0
lines changed

10 files changed

+215
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,7 @@ set(NETDISSECT_SOURCE_LIST_C
13071307
print-dhcp6.c
13081308
print-domain.c
13091309
print-dsa.c
1310+
print-dsa-gsw1xx.c
13101311
print-dtp.c
13111312
print-dvmrp.c
13121313
print-eap.c

Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ LIBNETDISSECT_SRC=\
120120
print-dhcp6.c \
121121
print-domain.c \
122122
print-dsa.c \
123+
print-dsa-gsw1xx.c \
123124
print-dtp.c \
124125
print-dvmrp.c \
125126
print-eap.c \

ethertype.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@
182182
#ifndef ETHERTYPE_AOE
183183
#define ETHERTYPE_AOE 0x88a2
184184
#endif
185+
#ifndef ETHERTYPE_GSW1XX
186+
#define ETHERTYPE_GSW1XX 0x88c3
187+
#endif
185188
#ifndef ETHERTYPE_PTP
186189
#define ETHERTYPE_PTP 0x88f7
187190
#endif

netdissect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ extern void chdlc_if_print IF_PRINTER_ARGS;
556556
extern void cip_if_print IF_PRINTER_ARGS;
557557
extern void dsa_if_print IF_PRINTER_ARGS;
558558
extern void edsa_if_print IF_PRINTER_ARGS;
559+
extern void gsw1xx_if_print IF_PRINTER_ARGS;
559560
extern void enc_if_print IF_PRINTER_ARGS;
560561
extern void ether_if_print IF_PRINTER_ARGS;
561562
extern void fddi_if_print IF_PRINTER_ARGS;

print-dsa-gsw1xx.c

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/*
2+
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3+
* The Regents of the University of California. All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that: (1) source code distributions
7+
* retain the above copyright notice and this paragraph in its entirety, (2)
8+
* distributions including binary code include the above copyright notice and
9+
* this paragraph in its entirety in the documentation or other materials
10+
* provided with the distribution, and (3) all advertising materials mentioning
11+
* features or use of this software display the following acknowledgement:
12+
* ``This product includes software developed by the University of California,
13+
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14+
* the University nor the names of its contributors may be used to endorse
15+
* or promote products derived from this software without specific prior
16+
* written permission.
17+
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18+
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20+
*/
21+
22+
/* based on print-dsa.c */
23+
24+
/* \summary: MaxLinear (Ethertype) Distributed Switch Architecture */
25+
26+
#ifdef HAVE_CONFIG_H
27+
#include <config.h>
28+
#endif
29+
30+
#include "netdissect-stdinc.h"
31+
32+
#include "netdissect.h"
33+
#include "ethertype.h"
34+
#include "addrtoname.h"
35+
#include "extract.h"
36+
37+
/*
38+
* Ingress and Egress have different formats.
39+
*
40+
* Format of (Ethertyped) Ingress tagged frames:
41+
*
42+
* 0 +----+----+----+----+----+----+----+----+
43+
* | Ether Destination Address |
44+
* +6 +----+----+----+----+----+----+----+----+
45+
* | Ether Source Address |
46+
* +6 +----+----+----+----+----+----+----+----+ +-
47+
* | Prog. DSA Ether Type [15:8] | | (8-byte) Special Tag
48+
* +1 +----+----+----+----+----+----+----+----+ | Contains a programmable Ether type.
49+
* | Prog. DSA Ether Type [7:0] | | +
50+
* +1 +----+----+----+----+----+----+----+----+ | | (6-byte) Special Tag Content
51+
* |PME[7] TCE[6] TSE[5] FNL[4] TTC[3:0] | | |
52+
* +1 +----+----+----+----+----+----+----+----+ | |
53+
* | TEPML [7:0] | | |
54+
* +1 +----+----+----+----+----+----+----+----+ | |
55+
* | TEPMH [7:0] | | |
56+
* +1 +----+----+----+----+----+----+----+----+ | |
57+
* | Res[7:5] IE[4] SP[3:0] | | |
58+
* +1 +----+----+----+----+----+----+----+----+ | |
59+
* | Res [7:0] all zero | | |
60+
* +1 +----+----+----+----+----+----+----+----+ | |
61+
* | Res [7:0] all zero | | |
62+
* +1 +----+----+----+----+----+----+----+----+ +- +-
63+
*
64+
* Format of (Ethertyped) Egress tagged frames:
65+
*
66+
* 0 +----+----+----+----+----+----+----+----+
67+
* | Ether Destination Address |
68+
* +6 +----+----+----+----+----+----+----+----+
69+
* | Ether Source Address |
70+
* +6 +----+----+----+----+----+----+----+----+ +-
71+
* | Prog. DSA Ether Type [15:8] | | (8-byte) Special Tag
72+
* +1 +----+----+----+----+----+----+----+----+ | Contains a programmable Ether type.
73+
* | Prog. DSA Ether Type [7:0] | | +
74+
* +1 +----+----+----+----+----+----+----+----+ | | (6-byte) Special Tag Content
75+
* | TC[7:4] IPN [3:0] | | |
76+
* +1 +----+----+----+----+----+----+----+----+ | |
77+
* | PPPOE[7] IPV[6] IPO[5:0] | | |
78+
* +1 +----+----+----+----+----+----+----+----+ | |
79+
* | DLPML [7:0] | | |
80+
* +1 +----+----+----+----+----+----+----+----+ | |
81+
* | DLPMR [7:0] | | |
82+
* +1 +----+----+----+----+----+----+----+----+ | |
83+
* | MI[7] KL2UM[6] PLHB[5:0] | | |
84+
* +1 +----+----+----+----+----+----+----+----+ | |
85+
* | PLLB [7:0] | | |
86+
* +2 +----+----+----+----+----+----+----+----+ +- +-
87+
* . . . . . . . . .
88+
*
89+
* PME: Port map enable
90+
* IPN: Ingress port number
91+
* TCE: Traffic class enable
92+
* TSE: Time stamp enable
93+
* FNL: Force no learning
94+
* TC: Traffic class
95+
* IPV: IPv4 packet
96+
* IPO: IP offset
97+
* SP: Source port
98+
* IE: Interrupt enable
99+
* PPPOE: ppp-over-ethernet
100+
* DLPML: Destination logical port map low bits.
101+
* DLPMR: Destination logical port map high (reserved)
102+
* MI: Mirror indication
103+
* KL2UM Known l2 unicast/multicast mac.
104+
* PLHB: Packet Length High Bits
105+
* PLLB: Packet Length Low Bits.
106+
* TEPML: Target egress port maps low bits
107+
* TEPMH: Target egress port maps high bits (reserved)
108+
* Res: Reserved
109+
*/
110+
111+
#define TOK(tag, byte, mask, shift) ((GET_U_1(&(((const u_char *) tag)[byte])) & (mask)) >> (shift))
112+
113+
#define GSW1XX_ET1(tag) TOK(tag, 0, 0xFF, 0)
114+
#define GSW1XX_ET2(tag) TOK(tag, 1, 0xFF, 0)
115+
#define GSW1XX_TTC(tag) TOK(tag, 2, 0x08, 0)
116+
#define GSW1XX_IG_PME(tag) TOK(tag, 2, 0x80, 7)
117+
#define GSW1XX_IG_TCE(tag) TOK(tag, 2, 0x40, 6)
118+
#define GSW1XX_IG_TSE(tag) TOK(tag, 2, 0x20, 5)
119+
#define GSW1XX_IG_FNL(tag) TOK(tag, 2, 0x10, 4)
120+
#define GSW1XX_IG_SP(tag) TOK(tag, 2, 0x0F, 0)
121+
#define GSW1XX_IG_IE(tag) TOK(tag, 5, 0x10, 3)
122+
#define GSW1XX_EG_IPN(tag) TOK(tag, 2, 0x0F, 0)
123+
#define GSW1XX_EG_TC(tag) TOK(tag, 2, 0xF0, 4)
124+
#define GSW1XX_EG_POE(tag) TOK(tag, 2, 0x80, 7)
125+
#define GSW1XX_EG_IV4(tag) TOK(tag, 2, 0x40, 6)
126+
#define GSW1XX_EG_IPO(tag) TOK(tag, 3, 0x3F, 0)
127+
128+
#define GSW1XX_MAP_LOW(tag) TOK(tag, 3, 0xFF, 0)
129+
#define GSW1XX_MAP_HIGH(tag) TOK(tag, 4, 0xFF, 0)
130+
#define GSW1XX_MAP(tag) ((GSW1XX_MAP_HIGH(tag) << 8) + GSW1XX_MAP_LOW(tag))
131+
#define GSW1XX_LEN_LOW(tag) TOK(tag, 7, 0xFF, 0)
132+
#define GSW1XX_LEN_HIGH(tag) TOK(tag, 6, 0x3F, 0)
133+
#define GSW1XX_LEN(tag) ((GSW1XX_LEN_HIGH(tag) << 8) + GSW1XX_LEN_LOW(tag))
134+
135+
#define SPTAG_LEN 8
136+
137+
static void
138+
tag_common_print(netdissect_options *ndo, const u_char *p)
139+
{
140+
if (ndo->ndo_eflag ) {
141+
int egress = !!GSW1XX_LEN(p);
142+
143+
if (egress) {
144+
ND_PRINT("Egress Port %d,", GSW1XX_EG_IPN(p));
145+
if (ndo->ndo_eflag > 1) {
146+
ND_PRINT("TTC %d,", GSW1XX_TTC(p));
147+
ND_PRINT("TC %d,", GSW1XX_EG_TC(p));
148+
ND_PRINT("IPN %d,", GSW1XX_EG_IPN(p));
149+
ND_PRINT("POE %d,", GSW1XX_EG_POE(p));
150+
if (GSW1XX_EG_IPO(p)) {
151+
ND_PRINT("IV4 %d,", GSW1XX_EG_IV4(p));
152+
ND_PRINT("IPO %d,", GSW1XX_EG_IPO(p));
153+
}
154+
ND_PRINT("Len %d,", GSW1XX_LEN(p));
155+
}
156+
} else {
157+
ND_PRINT("Ingress Port %d,", GSW1XX_IG_SP(p));
158+
ND_PRINT("MAP %d,", GSW1XX_MAP(p));
159+
if (ndo->ndo_eflag > 1) {
160+
ND_PRINT("PME %d,", GSW1XX_IG_PME(p));
161+
ND_PRINT("TCE %d,", GSW1XX_IG_TCE(p));
162+
ND_PRINT("TTC %d,", GSW1XX_TTC(p));
163+
ND_PRINT("FNL %d,", GSW1XX_IG_FNL(p));
164+
ND_PRINT("IE %d,", GSW1XX_IG_IE(p));
165+
ND_PRINT("TSE %d,", GSW1XX_IG_TSE(p));
166+
}
167+
}
168+
}
169+
}
170+
171+
static void
172+
gsw1xx_tag_print(netdissect_options *ndo, const u_char *bp)
173+
{
174+
const u_char *p = bp;
175+
uint16_t sptag_etype;
176+
177+
sptag_etype = GET_BE_U_2(p);
178+
if (ndo->ndo_eflag > 2) {
179+
ND_PRINT("MaxLinear ethertype 0x%04x (%s), ", sptag_etype,
180+
tok2str(ethertype_values, "Unknown", sptag_etype));
181+
} else {
182+
if (sptag_etype == ETHERTYPE_GSW1XX)
183+
ND_PRINT("GSW1XX ");
184+
else
185+
ND_PRINT("GSW1XX Unknown 0x%04x, ", sptag_etype);
186+
}
187+
tag_common_print(ndo, p);
188+
}
189+
190+
void
191+
gsw1xx_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
192+
{
193+
u_int caplen = h->caplen;
194+
u_int length = h->len;
195+
196+
ndo->ndo_protocol = "gsw1xx";
197+
ndo->ndo_ll_hdr_len +=
198+
ether_switch_tag_print(ndo, p, length, caplen, gsw1xx_tag_print, SPTAG_LEN);
199+
}

print-ether.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const struct tok ethertype_values[] = {
102102
{ ETHERTYPE_AOE, "AoE" },
103103
{ ETHERTYPE_PTP, "PTP" },
104104
{ ETHERTYPE_ARISTA, "Arista Vendor Specific Protocol" },
105+
{ ETHERTYPE_GSW1XX, "GSW1XX" },
105106
{ 0, NULL}
106107
};
107108

print.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ static const struct printer printers[] = {
7979
#ifdef DLT_DSA_TAG_EDSA
8080
{ edsa_if_print, DLT_DSA_TAG_EDSA },
8181
#endif
82+
#ifdef DLT_DSA_TAG_GSW1XX
83+
{ gsw1xx_if_print, DLT_DSA_TAG_GSW1XX },
84+
#endif
8285
#ifdef DLT_ENC
8386
{ enc_if_print, DLT_ENC },
8487
#endif

tests/TESTLIST

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ edsa-e edsa.pcap edsa-e.out -e
108108
edsa-high-vid edsa-high-vid.pcap edsa-high-vid.out
109109
edsa-high-vid-e edsa-high-vid.pcap edsa-high-vid-e.out -e
110110

111+
# MaxLinear DSA tag tests
112+
gsw1xx gsw1xx.pcap gsw1xx.out -n -e
113+
111114
# ESP tests
112115
esp0 02-sunrise-sunset-esp.pcap esp0.out
113116
esp_truncated esp_truncated.pcap esp_truncated.out

tests/gsw1xx.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1 2025-12-04 14:15:35.163012 b8:a4:4f:fc:53:8a > 01:00:5e:00:00:fb, GSW1XX Ingress Port 0,MAP 2,ethertype IPv4 (0x0800), length 362: 192.168.0.240.5353 > 224.0.0.251.5353: 0*- [0q] 3/0/4 (Cache flush) PTR axis-b8a44ffc538a.local., (Cache flush) PTR axis-b8a44ffc538a.local., (Cache flush) PTR axis-b8a44ffc538a.local. (312)
2+
2 2025-12-04 14:15:35.163727 b8:a4:4f:fc:53:8a > 1c:fd:08:7c:0a:e1, GSW1XX Ingress Port 0,MAP 2,ethertype IPv4 (0x0800), length 214: 192.168.0.240.22 > 192.168.0.1.43256: Flags [P.], seq 3228238683:3228238823, ack 1362097168, win 501, options [nop,nop,TS val 1250645671 ecr 99858784], length 140
3+
3 2025-12-04 14:15:35.164152 1c:fd:08:7c:0a:e1 > b8:a4:4f:fc:53:8a, GSW1XX Egress Port 1,ethertype IPv4 (0x0800), length 74: 192.168.0.1.43256 > 192.168.0.240.22: Flags [.], ack 140, win 2529, options [nop,nop,TS val 99858794 ecr 1250645662], length 0

tests/gsw1xx.pcap

722 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)