]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net: dsa: mv88e6xxx: Refactor setting of jumbo frames
authorAndrew Lunn <andrew@lunn.ch>
Sat, 3 Dec 2016 03:45:17 +0000 (04:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Dec 2016 04:18:38 +0000 (23:18 -0500)
Some switches support jumbo frames. Refactor this code into operations
in the ops structure.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
drivers/net/dsa/mv88e6xxx/port.c
drivers/net/dsa/mv88e6xxx/port.h

index b2b6fe3ef4bf73f093de2bd351e336b0d84f77e2..db1542e05e6220021b582ecb1b0c51e70be282ad 100644 (file)
@@ -2582,10 +2582,6 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
            mv88e6xxx_6185_family(chip))
                reg = PORT_CONTROL_2_MAP_DA;
 
-       if (mv88e6xxx_6352_family(chip) || mv88e6xxx_6351_family(chip) ||
-           mv88e6xxx_6165_family(chip) || mv88e6xxx_6320_family(chip))
-               reg |= PORT_CONTROL_2_JUMBO_10240;
-
        if (mv88e6xxx_6095_family(chip) || mv88e6xxx_6185_family(chip)) {
                /* Set the upstream port this port should use */
                reg |= dsa_upstream_port(ds);
@@ -2604,6 +2600,12 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
                        return err;
        }
 
+       if (chip->info->ops->port_jumbo_config) {
+               err = chip->info->ops->port_jumbo_config(chip, port);
+               if (err)
+                       return err;
+       }
+
        /* Port Association Vector: when learning source addresses
         * of packets, add the address to the address database using
         * a port bitmap that has only the bit for this port set and
@@ -2663,6 +2665,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
                                           0x0001);
                if (err)
                        return err;
+
        } else if (mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip)) {
                err = mv88e6xxx_port_write(chip, port, PORT_RATE_CONTROL,
                                           0x0000);
@@ -3264,6 +3267,7 @@ static const struct mv88e6xxx_ops mv88e6097_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3304,6 +3308,7 @@ static const struct mv88e6xxx_ops mv88e6131_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3325,6 +3330,7 @@ static const struct mv88e6xxx_ops mv88e6161_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3364,6 +3370,7 @@ static const struct mv88e6xxx_ops mv88e6171_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3388,6 +3395,7 @@ static const struct mv88e6xxx_ops mv88e6172_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3410,6 +3418,7 @@ static const struct mv88e6xxx_ops mv88e6175_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3434,6 +3443,7 @@ static const struct mv88e6xxx_ops mv88e6176_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3546,6 +3556,7 @@ static const struct mv88e6xxx_ops mv88e6240_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3592,6 +3603,7 @@ static const struct mv88e6xxx_ops mv88e6320_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6320_stats_get_sset_count,
        .stats_get_strings = mv88e6320_stats_get_strings,
@@ -3615,6 +3627,7 @@ static const struct mv88e6xxx_ops mv88e6321_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6320_stats_get_sset_count,
        .stats_get_strings = mv88e6320_stats_get_strings,
@@ -3636,6 +3649,7 @@ static const struct mv88e6xxx_ops mv88e6350_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3658,6 +3672,7 @@ static const struct mv88e6xxx_ops mv88e6351_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3682,6 +3697,7 @@ static const struct mv88e6xxx_ops mv88e6352_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6320_g1_stats_snapshot,
        .stats_get_sset_count = mv88e6095_stats_get_sset_count,
        .stats_get_strings = mv88e6095_stats_get_strings,
@@ -3704,6 +3720,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6390_g1_stats_snapshot,
        .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
        .stats_get_sset_count = mv88e6320_stats_get_sset_count,
@@ -3727,6 +3744,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {
        .port_set_frame_mode = mv88e6351_port_set_frame_mode,
        .port_set_egress_unknowns = mv88e6351_port_set_egress_unknowns,
        .port_set_ether_type = mv88e6351_port_set_ether_type,
+       .port_jumbo_config = mv88e6165_port_jumbo_config,
        .stats_snapshot = mv88e6390_g1_stats_snapshot,
        .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
        .stats_get_sset_count = mv88e6320_stats_get_sset_count,
index d9ffa96fe875a240e3433d401b24fd55fe667f12..d4f18b8209ec8f6b984754d68d1b14ae076de3ca 100644 (file)
@@ -833,6 +833,7 @@ struct mv88e6xxx_ops {
                                        bool on);
        int (*port_set_ether_type)(struct mv88e6xxx_chip *chip, int port,
                                   u16 etype);
+       int (*port_jumbo_config)(struct mv88e6xxx_chip *chip, int port);
 
        /* Snapshot the statistics for a port. The statistics can then
         * be read back a leisure but still with a consistent view.
index cf6674911abfbbf6884e9c45c29c136abf1bcc4b..a739129ce5e5f50b0af4bdb6fc1605e667ef2b0b 100644 (file)
@@ -607,6 +607,20 @@ int mv88e6xxx_port_set_8021q_mode(struct mv88e6xxx_chip *chip, int port,
        return 0;
 }
 
+int mv88e6165_port_jumbo_config(struct mv88e6xxx_chip *chip, int port)
+{
+       u16 reg;
+       int err;
+
+       err = mv88e6xxx_port_read(chip, port, PORT_CONTROL_2, &reg);
+       if (err)
+               return err;
+
+       reg |= PORT_CONTROL_2_JUMBO_10240;
+
+       return mv88e6xxx_port_write(chip, port, PORT_CONTROL_2, reg);
+}
+
 /* Offset 0x0f: Port Ether type */
 
 int mv88e6351_port_set_ether_type(struct mv88e6xxx_chip *chip, int port,
index 83cb3440e067b39aaba0a9e1cec01622ded2939d..9e25735c287efca7f81f3f4b7d13bad633581511 100644 (file)
@@ -62,6 +62,6 @@ int mv88e6351_port_set_egress_unknowns(struct mv88e6xxx_chip *chip, int port,
                                       bool on);
 int mv88e6351_port_set_ether_type(struct mv88e6xxx_chip *chip, int port,
                                  u16 etype);
-
+int mv88e6165_port_jumbo_config(struct mv88e6xxx_chip *chip, int port);
 
 #endif /* _MV88E6XXX_PORT_H */