View | Details | Raw Unified | Return to bug 211462
Collapse All | Expand All

(-)sbin/etherswitchcfg/etherswitchcfg.8 (-29 / +38 lines)
Lines 33-58 Link Here
33
.Sh SYNOPSIS
33
.Sh SYNOPSIS
34
.Nm
34
.Nm
35
.Op Fl "f control file"
35
.Op Fl "f control file"
36
.Ar info
36
.Cm info
37
.Nm
37
.Nm
38
.Op Fl "f control file"
38
.Op Fl "f control file"
39
.Ar config
39
.Cm config
40
.Ar command parameter
40
.Ar command parameter
41
.Nm
41
.Nm
42
.Op Fl "f control file"
42
.Op Fl "f control file"
43
.Ar phy
43
.Cm phy
44
.Ar phy.register[=value]
44
.Ar phy.register[=value]
45
.Nm
45
.Nm
46
.Op Fl "f control file"
46
.Op Fl "f control file"
47
.Ar port%d
47
.Cm port%d
48
.Ar [flags] command parameter
48
.Ar [flags] command parameter
49
.Nm
49
.Nm
50
.Op Fl "f control file"
50
.Op Fl "f control file"
51
.Ar reg
51
.Cm reg
52
.Ar register[=value]
52
.Ar register[=value]
53
.Nm
53
.Nm
54
.Op Fl "f control file"
54
.Op Fl "f control file"
55
.Ar vlangroup%d
55
.Cm vlangroup%d
56
.Ar command parameter
56
.Ar command parameter
57
.Sh DESCRIPTION
57
.Sh DESCRIPTION
58
The
58
The
Lines 81-88 The config command provides access to global switc Link Here
81
parameters.
81
parameters.
82
It support the following commands:
82
It support the following commands:
83
.Pp
83
.Pp
84
.Bl -tag -width ".Ar vlan_mode mode" -compact
84
.Bl -tag -width ".Cm vlan_mode mode" -compact
85
.It Ar vlan_mode mode
85
.It Cm vlan_mode Ar mode
86
Sets the switch VLAN mode (depends on the hardware).
86
Sets the switch VLAN mode (depends on the hardware).
87
.El
87
.El
88
.Ss phy
88
.Ss phy
Lines 103-153 The port command selects one of the ports of the s Link Here
103
It supports the following commands:
103
It supports the following commands:
104
.Pp
104
.Pp
105
.Bl -tag -width ".Ar pvid number" -compact
105
.Bl -tag -width ".Ar pvid number" -compact
106
.It Ar pvid number
106
.It Cm pvid Ar number
107
Sets the default port VID that is used to process incoming frames that are not tagged.
107
Sets the default port VID that is used to process incoming frames that are not tagged.
108
.It Ar media mediaspec
108
.It Cm media Ar mediaspec
109
Specifies the physical media configuration to be configured for a port.
109
Specifies the physical media configuration to be configured for a port.
110
.It Ar mediaopt mediaoption
110
.It Cm mediaopt Ar mediaoption
111
Specifies a list of media options for a port.
111
Specifies a list of media options for a port.
112
See
112
See
113
.Xr ifconfig 8
113
.Xr ifconfig 8
114
for details on
114
for details on
115
.Ar media
115
.Cm media
116
and
116
and
117
.Ar mediaopt .
117
.Cm mediaopt .
118
.It Cm led Ar number style
119
Sets the display style for a given LED.  Available styles are: 
120
.Cm default 
121
(usually flash on activity),
122
.Cm on , 
123
.Cm off , 
124
and 
125
.Cm blink .
126
Not all switches will support all styles.
118
.El
127
.El
119
.Pp
128
.Pp
120
And the following flags (please note that not all flags
129
And the following flags (please note that not all flags
121
are supported by all switch drivers):
130
are supported by all switch drivers):
122
.Pp
131
.Pp
123
.Bl -tag -width ".Ar addtag" -compact
132
.Bl -tag -width ".Fl addtag" -compact
124
.It Ar addtag
133
.It Cm addtag
125
Add VLAN tag to each packet sent by the port.
134
Add VLAN tag to each packet sent by the port.
126
.It Ar -addtag
135
.It Fl addtag
127
Disable the add VLAN tag option.
136
Disable the add VLAN tag option.
128
.It Ar striptag
137
.It Cm striptag
129
Strip the VLAN tags from the packets sent by the port.
138
Strip the VLAN tags from the packets sent by the port.
130
.It Ar -striptag
139
.It Fl striptag
131
Disable the strip VLAN tag option.
140
Disable the strip VLAN tag option.
132
.It Ar firstlock
141
.It Cm firstlock
133
This options makes the switch port lock on the first MAC address it sees.
142
This options makes the switch port lock on the first MAC address it sees.
134
After that, usually you need to reset the switch to learn different
143
After that, usually you need to reset the switch to learn different
135
MAC addresses.
144
MAC addresses.
136
.It Ar -firstlock
145
.It Fl firstlock
137
Disable the first lock option.
146
Disable the first lock option.
138
Note that sometimes you need to reset the
147
Note that sometimes you need to reset the
139
switch to really disable this option.
148
switch to really disable this option.
140
.It Ar dropuntagged
149
.It Cm dropuntagged
141
Drop packets without a VLAN tag.
150
Drop packets without a VLAN tag.
142
.It Ar -dropuntagged
151
.It Fl dropuntagged
143
Disable the drop untagged packets option.
152
Disable the drop untagged packets option.
144
.It Ar doubletag
153
.It Cm doubletag
145
Enable QinQ for the port.
154
Enable QinQ for the port.
146
.It Ar -doubletag
155
.It Fl doubletag
147
Disable QinQ for the port.
156
Disable QinQ for the port.
148
.It Ar ingress
157
.It Cm ingress
149
Enable the ingress filter on the port.
158
Enable the ingress filter on the port.
150
.It Ar -ingress
159
.It Fl ingress
151
Disable the ingress filter.
160
Disable the ingress filter.
152
.El
161
.El
153
.Ss reg
162
.Ss reg
Lines 156-169 The reg command provides access to the registers o Link Here
156
The vlangroup command selects one of the VLAN groups for configuration.
165
The vlangroup command selects one of the VLAN groups for configuration.
157
It supports the following commands:
166
It supports the following commands:
158
.Pp
167
.Pp
159
.Bl -tag -width ".Ar vlangroup" -compact
168
.Bl -tag -width ".Cm members" -compact
160
.It Ar vlan VID
169
.It Cm vlan Ar VID
161
Sets the VLAN ID (802.1q VID) for this VLAN group.
170
Sets the VLAN ID (802.1q VID) for this VLAN group.
162
Frames transmitted on tagged member ports of this group will be tagged
171
Frames transmitted on tagged member ports of this group will be tagged
163
with this VID.
172
with this VID.
164
Incoming frames carrying this tag will be forwarded according to the
173
Incoming frames carrying this tag will be forwarded according to the
165
configuration of this VLAN group.
174
configuration of this VLAN group.
166
.It Ar members port,...
175
.It Cm members Ar port,...
167
Configures which ports are to be a member of this VLAN group.
176
Configures which ports are to be a member of this VLAN group.
168
The port numbers are given as a comma-separated list.
177
The port numbers are given as a comma-separated list.
169
Each port can optionally be followed by
178
Each port can optionally be followed by
(-)sbin/etherswitchcfg/etherswitchcfg.c (-5 / +47 lines)
Lines 83-88 struct cmds { Link Here
83
};
83
};
84
static struct cmds cmds[];
84
static struct cmds cmds[];
85
85
86
/* Must match the ETHERSWITCH_PORT_LED_* enum order */
87
static const char *ledstyles[] = { "default", "on", "off", "blink", NULL };
86
88
87
/*
89
/*
88
 * Print a value a la the %b format of the kernel's printf.
90
 * Print a value a la the %b format of the kernel's printf.
Lines 270-275 set_port_mediaopt(struct cfg *cfg, char *argv[]) Link Here
270
}
272
}
271
273
272
static void
274
static void
275
set_port_led(struct cfg *cfg, char *argv[])
276
{
277
	etherswitch_port_t p;
278
	int led;
279
	int i;
280
	
281
	bzero(&p, sizeof(p));
282
	p.es_port = cfg->unit;
283
	if (ioctl(cfg->fd, IOETHERSWITCHGETPORT, &p) != 0)
284
		err(EX_OSERR, "ioctl(IOETHERSWITCHGETPORT)");
285
286
	led = strtol(argv[1], NULL, 0);
287
	if (led < 1 || led > p.es_nleds)
288
		errx(EX_USAGE, "invalid led number %s; must be between 1 and %d",
289
			argv[1], p.es_nleds);
290
291
	led--;
292
293
	for (i=0; ledstyles[i] != NULL; i++) {
294
		if (strcmp(argv[2], ledstyles[i]) == 0) {
295
			p.es_led[led] = i;
296
			break;
297
		}
298
	} 
299
	if (ledstyles[i] == NULL)
300
		errx(EX_USAGE, "invalid led style \"%s\"", argv[2]);
301
302
	if (ioctl(cfg->fd, IOETHERSWITCHSETPORT, &p) != 0)
303
		err(EX_OSERR, "ioctl(IOETHERSWITCHSETPORT)");
304
}
305
306
static void
273
set_vlangroup_vid(struct cfg *cfg, char *argv[])
307
set_vlangroup_vid(struct cfg *cfg, char *argv[])
274
{
308
{
275
	int v;
309
	int v;
Lines 334-343 set_register(struct cfg *cfg, char *arg) Link Here
334
	if (c==arg)
368
	if (c==arg)
335
		return (1);
369
		return (1);
336
	if (*c == '=') {
370
	if (*c == '=') {
337
		v = strtol(c+1, NULL, 0);
371
		v = strtoul(c+1, NULL, 0);
338
		write_register(cfg, a, v);
372
		write_register(cfg, a, v);
339
	}
373
	}
340
	printf("\treg 0x%04x=0x%04x\n", a, read_register(cfg, a));
374
	printf("\treg 0x%04x=0x%08x\n", a, read_register(cfg, a));
341
	return (0);
375
	return (0);
342
}
376
}
343
377
Lines 357-363 set_phyregister(struct cfg *cfg, char *arg) Link Here
357
	if (d == c)
391
	if (d == c)
358
		return (1);
392
		return (1);
359
	if (*c == '=') {
393
	if (*c == '=') {
360
		val = strtol(c+1, NULL, 0);
394
		val = strtoul(c+1, NULL, 0);
361
		write_phyregister(cfg, phy, reg, val);
395
		write_phyregister(cfg, phy, reg, val);
362
	}
396
	}
363
	printf("\treg %d.0x%02x=0x%04x\n", phy, reg, read_phyregister(cfg, phy, reg));
397
	printf("\treg %d.0x%02x=0x%04x\n", phy, reg, read_phyregister(cfg, phy, reg));
Lines 442-447 print_port(struct cfg *cfg, int port) Link Here
442
		printf("\tpvid: %d\n", p.es_pvid);
476
		printf("\tpvid: %d\n", p.es_pvid);
443
	printb("\tflags", p.es_flags, ETHERSWITCH_PORT_FLAGS_BITS);
477
	printb("\tflags", p.es_flags, ETHERSWITCH_PORT_FLAGS_BITS);
444
	printf("\n");
478
	printf("\n");
479
	if (p.es_nleds) {
480
		printf("\tled: ");
481
		for (i = 0; i < p.es_nleds; i++) {
482
			printf("%d:%s%s", i+1, ledstyles[p.es_led[i]], (i==p.es_nleds-1)?"":" ");
483
		}
484
		printf("\n");
485
	}
445
	printf("\tmedia: ");
486
	printf("\tmedia: ");
446
	print_media_word(p.es_ifmr.ifm_current, 1);
487
	print_media_word(p.es_ifmr.ifm_current, 1);
447
	if (p.es_ifmr.ifm_active != p.es_ifmr.ifm_current) {
488
	if (p.es_ifmr.ifm_active != p.es_ifmr.ifm_current) {
Lines 540-546 usage(struct cfg *cfg __unused, char *argv[] __unu Link Here
540
	    "phy.register[=value]\n");
581
	    "phy.register[=value]\n");
541
	fprintf(stderr, "\tetherswitchcfg [-f control file] portX "
582
	fprintf(stderr, "\tetherswitchcfg [-f control file] portX "
542
	    "[flags] command parameter\n");
583
	    "[flags] command parameter\n");
543
	fprintf(stderr, "\t\tport commands: pvid, media, mediaopt\n");
584
	fprintf(stderr, "\t\tport commands: pvid, media, mediaopt, led\n");
544
	fprintf(stderr, "\tetherswitchcfg [-f control file] reg "
585
	fprintf(stderr, "\tetherswitchcfg [-f control file] reg "
545
	    "register[=value]\n");
586
	    "register[=value]\n");
546
	fprintf(stderr, "\tetherswitchcfg [-f control file] vlangroupX "
587
	fprintf(stderr, "\tetherswitchcfg [-f control file] vlangroupX "
Lines 651-657 main(int argc, char *argv[]) Link Here
651
			for(i=0; cmds[i].name != NULL; i++) {
692
			for(i=0; cmds[i].name != NULL; i++) {
652
				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0) {
693
				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0) {
653
					if (argc < (cmds[i].args + 1)) {
694
					if (argc < (cmds[i].args + 1)) {
654
						printf("%s needs an argument\n", cmds[i].name);
695
						printf("%s needs %d argument%s\n", cmds[i].name, cmds[i].args, (cmds[i].args==1)?"":",");
655
						break;
696
						break;
656
					}
697
					}
657
					(cmds[i].f)(&cfg, argv);
698
					(cmds[i].f)(&cfg, argv);
Lines 691-696 static struct cmds cmds[] = { Link Here
691
	{ MODE_PORT, "pvid", 1, set_port_vid },
732
	{ MODE_PORT, "pvid", 1, set_port_vid },
692
	{ MODE_PORT, "media", 1, set_port_media },
733
	{ MODE_PORT, "media", 1, set_port_media },
693
	{ MODE_PORT, "mediaopt", 1, set_port_mediaopt },
734
	{ MODE_PORT, "mediaopt", 1, set_port_mediaopt },
735
	{ MODE_PORT, "led", 2, set_port_led },
694
	{ MODE_PORT, "addtag", 0, set_port_flag },
736
	{ MODE_PORT, "addtag", 0, set_port_flag },
695
	{ MODE_PORT, "-addtag", 0, set_port_flag },
737
	{ MODE_PORT, "-addtag", 0, set_port_flag },
696
	{ MODE_PORT, "ingress", 0, set_port_flag },
738
	{ MODE_PORT, "ingress", 0, set_port_flag },
(-)sys/dev/etherswitch/arswitch/arswitch.c (-4 / +108 lines)
Lines 69-74 Link Here
69
#include <dev/etherswitch/arswitch/arswitch_8327.h>
69
#include <dev/etherswitch/arswitch/arswitch_8327.h>
70
#include <dev/etherswitch/arswitch/arswitch_9340.h>
70
#include <dev/etherswitch/arswitch/arswitch_9340.h>
71
71
72
#include <dev/led/led.h>
73
72
#include "mdio_if.h"
74
#include "mdio_if.h"
73
#include "miibus_if.h"
75
#include "miibus_if.h"
74
#include "etherswitch_if.h"
76
#include "etherswitch_if.h"
Lines 77-82 Link Here
77
static SYSCTL_NODE(_debug, OID_AUTO, arswitch, CTLFLAG_RD, 0, "arswitch");
79
static SYSCTL_NODE(_debug, OID_AUTO, arswitch, CTLFLAG_RD, 0, "arswitch");
78
#endif
80
#endif
79
81
82
/* Map ETHERSWITCH_PORT_LED_* to Atheros pattern codes */
83
static int led_pattern_table[] = { 
84
	[ETHERSWITCH_PORT_LED_DEFAULT] = 0x3, 
85
	[ETHERSWITCH_PORT_LED_ON] = 0x2, 
86
	[ETHERSWITCH_PORT_LED_OFF] = 0x0, 
87
	[ETHERSWITCH_PORT_LED_BLINK] = 0x1 
88
};
89
80
static inline int arswitch_portforphy(int phy);
90
static inline int arswitch_portforphy(int phy);
81
static void arswitch_tick(void *arg);
91
static void arswitch_tick(void *arg);
82
static int arswitch_ifmedia_upd(struct ifnet *);
92
static int arswitch_ifmedia_upd(struct ifnet *);
Lines 85-90 static int ar8xxx_port_vlan_setup(struct arswitch_ Link Here
85
    etherswitch_port_t *p);
95
    etherswitch_port_t *p);
86
static int ar8xxx_port_vlan_get(struct arswitch_softc *sc,
96
static int ar8xxx_port_vlan_get(struct arswitch_softc *sc,
87
    etherswitch_port_t *p);
97
    etherswitch_port_t *p);
98
static int arswitch_setled(struct arswitch_softc *sc, int phy, int led,
99
    int style);
100
static void arswitch_led_func(struct arswitch_dev_led *dev_led, int onoff);
88
101
89
static int
102
static int
90
arswitch_probe(device_t dev)
103
arswitch_probe(device_t dev)
Lines 188-196 arswitch_attach_phys(struct arswitch_softc *sc) Link Here
188
			device_printf(sc->sc_dev,
201
			device_printf(sc->sc_dev,
189
			    "attaching PHY %d failed\n",
202
			    "attaching PHY %d failed\n",
190
			    phy);
203
			    phy);
204
			return (err);
191
		}
205
		}
206
207
		if (AR8X16_IS_SWITCH(sc, AR8327)) {
208
			int led;
209
			char ledname[IFNAMSIZ+4];
210
211
			for (led = 0; led < 3; led++) {
212
				sprintf(ledname, "%s%dled%d", name, 
213
				    arswitch_portforphy(phy), led+1);
214
				sc->dev_led[phy][led].sc = sc;
215
				sc->dev_led[phy][led].led = 
216
				    led_create((led_t *)arswitch_led_func,
217
				    &sc->dev_led[phy][led], ledname);
218
				sc->dev_led[phy][led].phy = phy;
219
				sc->dev_led[phy][led].lednum = led;
220
			}
221
		}
192
	}
222
	}
193
	return (err);
223
	return (0);
194
}
224
}
195
225
196
static int
226
static int
Lines 422-428 static int Link Here
422
arswitch_detach(device_t dev)
452
arswitch_detach(device_t dev)
423
{
453
{
424
	struct arswitch_softc *sc = device_get_softc(dev);
454
	struct arswitch_softc *sc = device_get_softc(dev);
425
	int i;
455
	int i, led;
426
456
427
	callout_drain(&sc->callout_tick);
457
	callout_drain(&sc->callout_tick);
428
458
Lines 432-437 arswitch_detach(device_t dev) Link Here
432
		if (sc->ifp[i] != NULL)
462
		if (sc->ifp[i] != NULL)
433
			if_free(sc->ifp[i]);
463
			if_free(sc->ifp[i]);
434
		free(sc->ifname[i], M_DEVBUF);
464
		free(sc->ifname[i], M_DEVBUF);
465
		for (led=0; led < ARSWITCH_NUM_LEDS; led++) 
466
			if (sc->dev_led[i][led].led != NULL)
467
				led_destroy(sc->dev_led[i][led].led);
435
	}
468
	}
436
469
437
	bus_generic_detach(dev);
470
	bus_generic_detach(dev);
Lines 683-688 arswitch_getport(device_t dev, etherswitch_port_t Link Here
683
	} else {
716
	} else {
684
		return (ENXIO);
717
		return (ENXIO);
685
	}
718
	}
719
	
720
	if (!arswitch_is_cpuport(sc, p->es_port) && 
721
	    AR8X16_IS_SWITCH(sc, AR8327)) {
722
		int led;
723
		p->es_nleds = 3;
724
725
		for (led = 0; led < p->es_nleds; led++)
726
		{
727
			int style;
728
			uint32_t val;
729
			
730
			/* Find the right style enum for our pattern */
731
			val = arswitch_readreg(dev, 
732
			    ar8327_led_mapping[p->es_port-1][led].reg);
733
			val = (val>>ar8327_led_mapping[p->es_port-1][led].shift)&0x03;
734
			    
735
			for (style = 0; style < ETHERSWITCH_PORT_LED_MAX; style++)
736
			{
737
				if (led_pattern_table[style] == val) break;
738
			}
739
			
740
			/* can't happen */
741
			if (style == ETHERSWITCH_PORT_LED_MAX)
742
				style = ETHERSWITCH_PORT_LED_DEFAULT;
743
			
744
			p->es_led[led] = style;
745
		}
746
	} else
747
	{
748
		p->es_nleds = 0;
749
	}
750
	
686
	return (0);
751
	return (0);
687
}
752
}
688
753
Lines 727-733 ar8xxx_port_vlan_setup(struct arswitch_softc *sc, Link Here
727
static int
792
static int
728
arswitch_setport(device_t dev, etherswitch_port_t *p)
793
arswitch_setport(device_t dev, etherswitch_port_t *p)
729
{
794
{
730
	int err;
795
	int err, i;
731
	struct arswitch_softc *sc;
796
	struct arswitch_softc *sc;
732
	struct ifmedia *ifm;
797
	struct ifmedia *ifm;
733
	struct mii_data *mii;
798
	struct mii_data *mii;
Lines 744-752 arswitch_setport(device_t dev, etherswitch_port_t Link Here
744
			return (err);
809
			return (err);
745
	}
810
	}
746
811
747
	/* Do not allow media changes on CPU port. */
812
	/* Do not allow media or led changes on CPU port. */
748
	if (arswitch_is_cpuport(sc, p->es_port))
813
	if (arswitch_is_cpuport(sc, p->es_port))
749
		return (0);
814
		return (0);
815
	
816
	if (AR8X16_IS_SWITCH(sc, AR8327))
817
	{
818
		for (i = 0; i < 3; i++)
819
		{	
820
			int err;
821
			err = arswitch_setled(sc, p->es_port-1, i, p->es_led[i]);
822
			if (err)
823
				return (err);
824
		}
825
	}
750
826
751
	mii = arswitch_miiforport(sc, p->es_port);
827
	mii = arswitch_miiforport(sc, p->es_port);
752
	if (mii == NULL)
828
	if (mii == NULL)
Lines 758-763 arswitch_setport(device_t dev, etherswitch_port_t Link Here
758
	return (ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA));
834
	return (ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA));
759
}
835
}
760
836
837
/*
838
 * led(4) callback function.  That api only knows on/off; if you want to
839
 * reset back to defaults, you'll need to use etherswitchcfg.
840
 */
841
static void 
842
arswitch_led_func(struct arswitch_dev_led* dev_led, int onoff)
843
{
844
	arswitch_setled(dev_led->sc, dev_led->phy, dev_led->lednum, 
845
	    onoff ? ETHERSWITCH_PORT_LED_ON : ETHERSWITCH_PORT_LED_OFF);
846
}
847
848
static int
849
arswitch_setled(struct arswitch_softc *sc, int phy, int led, int style)
850
{
851
	int shift;
852
853
	if (phy < 0 || phy > sc->numphys)
854
		return EINVAL;
855
856
	if (style < 0 || style > ETHERSWITCH_PORT_LED_MAX)
857
		return (EINVAL);
858
    
859
	shift = ar8327_led_mapping[phy][led].shift;
860
	return (arswitch_modifyreg(sc->sc_dev, 
861
	    ar8327_led_mapping[phy][led].reg, 
862
	    0x03 << shift, led_pattern_table[style] << shift));
863
}
864
761
static void
865
static void
762
arswitch_statchg(device_t dev)
866
arswitch_statchg(device_t dev)
763
{
867
{
(-)sys/dev/etherswitch/arswitch/arswitch_8327.c (+30 lines)
Lines 75-80 Link Here
75
 * lead to traffic storms/loops.
75
 * lead to traffic storms/loops.
76
 */
76
 */
77
77
78
/* Map port+led to register+shift */
79
struct ar8327_led_mapping ar8327_led_mapping[AR8327_NUM_PHYS][ETHERSWITCH_PORT_MAX_LEDS] =
80
{
81
	{	/* PHY0 */
82
		{AR8327_REG_LED_CTRL0, 14 },
83
		{AR8327_REG_LED_CTRL1, 14 },
84
		{AR8327_REG_LED_CTRL2, 14 }
85
	},
86
	{	/* PHY1 */
87
		{AR8327_REG_LED_CTRL3, 8  },
88
		{AR8327_REG_LED_CTRL3, 10 },
89
		{AR8327_REG_LED_CTRL3, 12 }
90
	},
91
	{	/* PHY2 */
92
		{AR8327_REG_LED_CTRL3, 14 },
93
		{AR8327_REG_LED_CTRL3, 16 },
94
		{AR8327_REG_LED_CTRL3, 18 }
95
	},
96
	{	/* PHY3 */
97
		{AR8327_REG_LED_CTRL3, 20 },
98
		{AR8327_REG_LED_CTRL3, 22 },
99
		{AR8327_REG_LED_CTRL3, 24 }
100
	},
101
	{	/* PHY4 */
102
		{AR8327_REG_LED_CTRL0, 30 },
103
		{AR8327_REG_LED_CTRL1, 30 },
104
		{AR8327_REG_LED_CTRL2, 30 }
105
	}
106
};
107
78
static int
108
static int
79
ar8327_vlan_op(struct arswitch_softc *sc, uint32_t op, uint32_t vid,
109
ar8327_vlan_op(struct arswitch_softc *sc, uint32_t op, uint32_t vid,
80
    uint32_t data)
110
    uint32_t data)
(-)sys/dev/etherswitch/arswitch/arswitch_8327.h (+5 lines)
Lines 85-90 struct ar8327_port_cfg { Link Here
85
	uint32_t rxpause;
85
	uint32_t rxpause;
86
};
86
};
87
87
88
extern struct ar8327_led_mapping {
89
	int reg;
90
	int shift;
91
} ar8327_led_mapping[AR8327_NUM_PHYS][ETHERSWITCH_PORT_MAX_LEDS];
92
88
extern	void ar8327_attach(struct arswitch_softc *sc);
93
extern	void ar8327_attach(struct arswitch_softc *sc);
89
94
90
#endif	/* __ARSWITCH_8327_H__ */
95
#endif	/* __ARSWITCH_8327_H__ */
(-)sys/dev/etherswitch/arswitch/arswitchvar.h (+10 lines)
Lines 48-53 typedef enum { Link Here
48
#define ARSWITCH_NUM_PORTS	MAX(AR8327_NUM_PORTS, AR8X16_NUM_PORTS)
48
#define ARSWITCH_NUM_PORTS	MAX(AR8327_NUM_PORTS, AR8X16_NUM_PORTS)
49
#define ARSWITCH_NUM_PHYS	MAX(AR8327_NUM_PHYS, AR8X16_NUM_PHYS)
49
#define ARSWITCH_NUM_PHYS	MAX(AR8327_NUM_PHYS, AR8X16_NUM_PHYS)
50
50
51
#define ARSWITCH_NUM_LEDS	3
52
53
struct arswitch_dev_led {
54
	struct arswitch_softc	*sc;
55
	struct cdev	*led;
56
	int		phy;
57
	int		lednum;
58
};
59
51
struct arswitch_softc {
60
struct arswitch_softc {
52
	struct mtx	sc_mtx;		/* serialize access to softc */
61
	struct mtx	sc_mtx;		/* serialize access to softc */
53
	device_t	sc_dev;
62
	device_t	sc_dev;
Lines 66-71 struct arswitch_softc { Link Here
66
	char		*ifname[ARSWITCH_NUM_PHYS];
75
	char		*ifname[ARSWITCH_NUM_PHYS];
67
	device_t	miibus[ARSWITCH_NUM_PHYS];
76
	device_t	miibus[ARSWITCH_NUM_PHYS];
68
	struct ifnet	*ifp[ARSWITCH_NUM_PHYS];
77
	struct ifnet	*ifp[ARSWITCH_NUM_PHYS];
78
	struct arswitch_dev_led	dev_led[ARSWITCH_NUM_PHYS][ARSWITCH_NUM_LEDS];
69
	struct callout	callout_tick;
79
	struct callout	callout_tick;
70
	etherswitch_info_t info;
80
	etherswitch_info_t info;
71
81
(-)sys/dev/etherswitch/etherswitch.h (-1 / +14 lines)
Lines 14-20 extern driver_t etherswitch_driver; Link Here
14
14
15
struct etherswitch_reg {
15
struct etherswitch_reg {
16
	uint16_t	reg;
16
	uint16_t	reg;
17
	uint16_t	val;
17
	uint32_t	val;
18
};
18
};
19
typedef struct etherswitch_reg etherswitch_reg_t;
19
typedef struct etherswitch_reg etherswitch_reg_t;
20
20
Lines 64-73 typedef struct etherswitch_conf etherswitch_conf_t Link Here
64
#define	ETHERSWITCH_PORT_FLAGS_BITS	\
64
#define	ETHERSWITCH_PORT_FLAGS_BITS	\
65
"\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS"
65
"\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS"
66
66
67
#define ETHERSWITCH_PORT_MAX_LEDS 3
68
69
enum etherswitch_port_led {
70
	ETHERSWITCH_PORT_LED_DEFAULT,
71
	ETHERSWITCH_PORT_LED_ON,
72
	ETHERSWITCH_PORT_LED_OFF,
73
	ETHERSWITCH_PORT_LED_BLINK,
74
	ETHERSWITCH_PORT_LED_MAX
75
};
76
typedef enum etherswitch_port_led etherswitch_port_led_t;
77
67
struct etherswitch_port {
78
struct etherswitch_port {
68
	int		es_port;
79
	int		es_port;
69
	int		es_pvid;
80
	int		es_pvid;
81
	int		es_nleds;
70
	uint32_t	es_flags;
82
	uint32_t	es_flags;
83
	etherswitch_port_led_t es_led[ETHERSWITCH_PORT_MAX_LEDS];
71
	union {
84
	union {
72
		struct ifreq		es_uifr;
85
		struct ifreq		es_uifr;
73
		struct ifmediareq	es_uifmr;
86
		struct ifmediareq	es_uifmr;

Return to bug 211462