#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/dsa/ksz_common.h>
#include <linux/export.h>
#include <linux/gpio.h>
#include <linux/if_vlan.h>
return DSA_TAG_PROTO_KSZ9893;
}
+static int ksz8463_connect_tag_protocol(struct dsa_switch *ds,
+ enum dsa_tag_protocol proto)
+{
+ struct ksz_tagger_data *tagger_data;
+
+ if (proto != DSA_TAG_PROTO_KSZ9893)
+ return -EPROTONOSUPPORT;
+
+ tagger_data = ksz_tagger_data(ds);
+ tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+
+ return 0;
+}
+
static enum dsa_tag_protocol ksz87xx_get_tag_protocol(struct dsa_switch *ds,
int port,
enum dsa_tag_protocol mp)
return DSA_TAG_PROTO_KSZ8795;
}
+static int ksz87xx_connect_tag_protocol(struct dsa_switch *ds,
+ enum dsa_tag_protocol proto)
+{
+ if (proto != DSA_TAG_PROTO_KSZ8795)
+ return -EPROTONOSUPPORT;
+
+ return 0;
+}
+
static enum dsa_tag_protocol ksz88xx_get_tag_protocol(struct dsa_switch *ds,
int port,
enum dsa_tag_protocol mp)
return DSA_TAG_PROTO_KSZ9893;
}
+static int ksz88xx_connect_tag_protocol(struct dsa_switch *ds,
+ enum dsa_tag_protocol proto)
+{
+ struct ksz_tagger_data *tagger_data;
+
+ if (ksz_is_8895_family(ds->priv)) { /* KSZ8864, KSZ8895 */
+ if (proto != DSA_TAG_PROTO_KSZ8795)
+ return -EPROTONOSUPPORT;
+
+ return 0;
+ }
+
+ if (proto != DSA_TAG_PROTO_KSZ9893)
+ return -EPROTONOSUPPORT;
+
+ tagger_data = ksz_tagger_data(ds);
+ tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+
+ return 0;
+}
+
static void ksz88x3_phylink_mac_config(struct phylink_config *config,
unsigned int mode,
const struct phylink_link_state *state)
const struct dsa_switch_ops ksz8463_switch_ops = {
.get_tag_protocol = ksz8463_get_tag_protocol,
- .connect_tag_protocol = ksz_connect_tag_protocol,
+ .connect_tag_protocol = ksz8463_connect_tag_protocol,
.get_phy_flags = ksz_get_phy_flags,
.setup = ksz_setup,
.teardown = ksz_teardown,
const struct dsa_switch_ops ksz87xx_switch_ops = {
.get_tag_protocol = ksz87xx_get_tag_protocol,
- .connect_tag_protocol = ksz_connect_tag_protocol,
+ .connect_tag_protocol = ksz87xx_connect_tag_protocol,
.get_phy_flags = ksz_get_phy_flags,
.setup = ksz_setup,
.teardown = ksz_teardown,
const struct dsa_switch_ops ksz88xx_switch_ops = {
.get_tag_protocol = ksz88xx_get_tag_protocol,
- .connect_tag_protocol = ksz_connect_tag_protocol,
+ .connect_tag_protocol = ksz88xx_connect_tag_protocol,
.get_phy_flags = ksz_get_phy_flags,
.setup = ksz_setup,
.teardown = ksz_teardown,
* Copyright (C) 2017-2025 Microchip Technology Inc.
*/
+#include <linux/dsa/ksz_common.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/iopoll.h>
return DSA_TAG_PROTO_KSZ9477;
}
+static int ksz9477_connect_tag_protocol(struct dsa_switch *ds,
+ enum dsa_tag_protocol proto)
+{
+ struct ksz_tagger_data *tagger_data;
+
+ if (proto != DSA_TAG_PROTO_KSZ9893 && proto != DSA_TAG_PROTO_KSZ9477)
+ return -EPROTONOSUPPORT;
+
+ tagger_data = ksz_tagger_data(ds);
+ tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+
+ return 0;
+}
+
static void ksz9477_set_gbit(struct ksz_device *dev, int port, bool gbit)
{
const u8 *bitval = dev->info->xmii_ctrl1;
const struct dsa_switch_ops ksz9477_switch_ops = {
.get_tag_protocol = ksz9477_get_tag_protocol,
- .connect_tag_protocol = ksz_connect_tag_protocol,
+ .connect_tag_protocol = ksz9477_connect_tag_protocol,
.get_phy_flags = ksz_get_phy_flags,
.setup = ksz_setup,
.teardown = ksz_teardown,
return 0;
}
-int ksz_connect_tag_protocol(struct dsa_switch *ds,
- enum dsa_tag_protocol proto)
-{
- struct ksz_tagger_data *tagger_data;
-
- switch (proto) {
- case DSA_TAG_PROTO_KSZ8795:
- return 0;
- case DSA_TAG_PROTO_KSZ9893:
- case DSA_TAG_PROTO_KSZ9477:
- case DSA_TAG_PROTO_LAN937X:
- tagger_data = ksz_tagger_data(ds);
- tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
- return 0;
- default:
- return -EPROTONOSUPPORT;
- }
-}
-
int ksz_port_vlan_filtering(struct dsa_switch *ds, int port,
bool flag, struct netlink_ext_ack *extack)
{
int ksz_port_setup(struct dsa_switch *ds, int port);
void ksz_port_teardown(struct dsa_switch *ds, int port);
-int ksz_connect_tag_protocol(struct dsa_switch *ds,
- enum dsa_tag_protocol proto);
void ksz_init_mib_timer(struct ksz_device *dev);
bool ksz_is_port_mac_global_usable(struct dsa_switch *ds, int port);
void ksz_r_mib_stats64(struct ksz_device *dev, int port);
/* Microchip LAN937X switch driver main logic
* Copyright (C) 2019-2024 Microchip Technology Inc.
*/
+#include <linux/dsa/ksz_common.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/iopoll.h>
return DSA_TAG_PROTO_LAN937X;
}
+static int lan937x_connect_tag_protocol(struct dsa_switch *ds,
+ enum dsa_tag_protocol proto)
+{
+ struct ksz_tagger_data *tagger_data;
+
+ if (proto != DSA_TAG_PROTO_LAN937X)
+ return -EPROTONOSUPPORT;
+
+ tagger_data = ksz_tagger_data(ds);
+ tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+
+ return 0;
+}
+
const struct phylink_mac_ops lan937x_phylink_mac_ops = {
.mac_config = ksz_phylink_mac_config,
.mac_link_down = ksz_phylink_mac_link_down,
const struct dsa_switch_ops lan937x_switch_ops = {
.get_tag_protocol = lan937x_get_tag_protocol,
- .connect_tag_protocol = ksz_connect_tag_protocol,
+ .connect_tag_protocol = lan937x_connect_tag_protocol,
.get_phy_flags = ksz_get_phy_flags,
.setup = ksz_setup,
.teardown = ksz_teardown,