Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'mv88e6xxx-add-mab-offload-support'

Hans J. Schultz says:

====================
mv88e6xxx: Add MAB offload support

This patch-set adds MAB [1] offload support in mv88e6xxx.

Patch #1: Correct default return value for mv88e6xxx_port_bridge_flags.

Patch #2: Shorten the locked section in
mv88e6xxx_g1_atu_prob_irq_thread_fn().

Patch #3: The MAB implementation for mv88e6xxx.

[1] https://git.kernel.org/netdev/net-next/c/4bf24ad09bc0
====================

Link: https://lore.kernel.org/r/20230108094849.1789162-1-netdev@kapio-technology.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+148 -14
+1
drivers/net/dsa/mv88e6xxx/Makefile
··· 15 15 mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o 16 16 mv88e6xxx-objs += serdes.o 17 17 mv88e6xxx-objs += smi.o 18 + mv88e6xxx-objs += switchdev.o 18 19 mv88e6xxx-objs += trace.o 19 20 20 21 # for tracing framework to find trace.h
+13 -7
drivers/net/dsa/mv88e6xxx/chip.c
··· 1728 1728 return err; 1729 1729 } 1730 1730 1731 - static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, 1732 - int (*cb)(struct mv88e6xxx_chip *chip, 1733 - const struct mv88e6xxx_vtu_entry *entry, 1734 - void *priv), 1735 - void *priv) 1731 + int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, 1732 + int (*cb)(struct mv88e6xxx_chip *chip, 1733 + const struct mv88e6xxx_vtu_entry *entry, 1734 + void *priv), 1735 + void *priv) 1736 1736 { 1737 1737 struct mv88e6xxx_vtu_entry entry = { 1738 1738 .vid = mv88e6xxx_max_vid(chip), ··· 6526 6526 const struct mv88e6xxx_ops *ops; 6527 6527 6528 6528 if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | 6529 - BR_BCAST_FLOOD | BR_PORT_LOCKED)) 6529 + BR_BCAST_FLOOD | BR_PORT_LOCKED | BR_PORT_MAB)) 6530 6530 return -EINVAL; 6531 6531 6532 6532 ops = chip->info->ops; ··· 6545 6545 struct netlink_ext_ack *extack) 6546 6546 { 6547 6547 struct mv88e6xxx_chip *chip = ds->priv; 6548 - int err = -EOPNOTSUPP; 6548 + int err = 0; 6549 6549 6550 6550 mv88e6xxx_reg_lock(chip); 6551 6551 ··· 6582 6582 err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast); 6583 6583 if (err) 6584 6584 goto out; 6585 + } 6586 + 6587 + if (flags.mask & BR_PORT_MAB) { 6588 + bool mab = !!(flags.val & BR_PORT_MAB); 6589 + 6590 + mv88e6xxx_port_set_mab(chip, port, mab); 6585 6591 } 6586 6592 6587 6593 if (flags.mask & BR_PORT_LOCKED) {
+15
drivers/net/dsa/mv88e6xxx/chip.h
··· 280 280 unsigned int serdes_irq; 281 281 char serdes_irq_name[64]; 282 282 struct devlink_region *region; 283 + 284 + /* MacAuth Bypass control flag */ 285 + bool mab; 283 286 }; 284 287 285 288 enum mv88e6xxx_region_id { ··· 787 784 return (chip->info->invalid_port_mask & BIT(port)) != 0; 788 785 } 789 786 787 + static inline void mv88e6xxx_port_set_mab(struct mv88e6xxx_chip *chip, 788 + int port, bool mab) 789 + { 790 + chip->ports[port].mab = mab; 791 + } 792 + 790 793 int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val); 791 794 int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val); 792 795 int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, ··· 810 801 { 811 802 mutex_unlock(&chip->reg_lock); 812 803 } 804 + 805 + int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, 806 + int (*cb)(struct mv88e6xxx_chip *chip, 807 + const struct mv88e6xxx_vtu_entry *entry, 808 + void *priv), 809 + void *priv); 813 810 814 811 int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *bitmap); 815 812
+17 -7
drivers/net/dsa/mv88e6xxx/global1_atu.c
··· 12 12 13 13 #include "chip.h" 14 14 #include "global1.h" 15 + #include "switchdev.h" 15 16 #include "trace.h" 16 17 17 18 /* Offset 0x01: ATU FID Register */ ··· 410 409 411 410 err = mv88e6xxx_g1_read_atu_violation(chip); 412 411 if (err) 413 - goto out; 412 + goto out_unlock; 414 413 415 414 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_OP, &val); 416 415 if (err) 417 - goto out; 416 + goto out_unlock; 418 417 419 418 err = mv88e6xxx_g1_atu_fid_read(chip, &fid); 420 419 if (err) 421 - goto out; 420 + goto out_unlock; 422 421 423 422 err = mv88e6xxx_g1_atu_data_read(chip, &entry); 424 423 if (err) 425 - goto out; 424 + goto out_unlock; 426 425 427 426 err = mv88e6xxx_g1_atu_mac_read(chip, &entry); 428 427 if (err) 429 - goto out; 428 + goto out_unlock; 429 + 430 + mv88e6xxx_reg_unlock(chip); 430 431 431 432 spid = entry.state; 432 433 ··· 444 441 entry.portvec, entry.mac, 445 442 fid); 446 443 chip->ports[spid].atu_miss_violation++; 444 + 445 + if (fid != MV88E6XXX_FID_STANDALONE && chip->ports[spid].mab) { 446 + err = mv88e6xxx_handle_miss_violation(chip, spid, 447 + &entry, fid); 448 + if (err) 449 + goto out; 450 + } 447 451 } 448 452 449 453 if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) { ··· 459 449 fid); 460 450 chip->ports[spid].atu_full_violation++; 461 451 } 462 - mv88e6xxx_reg_unlock(chip); 463 452 464 453 return IRQ_HANDLED; 465 454 466 - out: 455 + out_unlock: 467 456 mv88e6xxx_reg_unlock(chip); 468 457 458 + out: 469 459 dev_err(chip->dev, "ATU problem: error %d while handling interrupt\n", 470 460 err); 471 461 return IRQ_HANDLED;
+83
drivers/net/dsa/mv88e6xxx/switchdev.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * switchdev.c 4 + * 5 + * Authors: 6 + * Hans J. Schultz <netdev@kapio-technology.com> 7 + * 8 + */ 9 + 10 + #include <net/switchdev.h> 11 + #include "chip.h" 12 + #include "global1.h" 13 + #include "switchdev.h" 14 + 15 + struct mv88e6xxx_fid_search_ctx { 16 + u16 fid_search; 17 + u16 vid_found; 18 + }; 19 + 20 + static int __mv88e6xxx_find_vid(struct mv88e6xxx_chip *chip, 21 + const struct mv88e6xxx_vtu_entry *entry, 22 + void *priv) 23 + { 24 + struct mv88e6xxx_fid_search_ctx *ctx = priv; 25 + 26 + if (ctx->fid_search == entry->fid) { 27 + ctx->vid_found = entry->vid; 28 + return 1; 29 + } 30 + 31 + return 0; 32 + } 33 + 34 + static int mv88e6xxx_find_vid(struct mv88e6xxx_chip *chip, u16 fid, u16 *vid) 35 + { 36 + struct mv88e6xxx_fid_search_ctx ctx; 37 + int err; 38 + 39 + ctx.fid_search = fid; 40 + mv88e6xxx_reg_lock(chip); 41 + err = mv88e6xxx_vtu_walk(chip, __mv88e6xxx_find_vid, &ctx); 42 + mv88e6xxx_reg_unlock(chip); 43 + if (err < 0) 44 + return err; 45 + if (err == 1) 46 + *vid = ctx.vid_found; 47 + else 48 + return -ENOENT; 49 + 50 + return 0; 51 + } 52 + 53 + int mv88e6xxx_handle_miss_violation(struct mv88e6xxx_chip *chip, int port, 54 + struct mv88e6xxx_atu_entry *entry, u16 fid) 55 + { 56 + struct switchdev_notifier_fdb_info info = { 57 + .addr = entry->mac, 58 + .locked = true, 59 + }; 60 + struct net_device *brport; 61 + struct dsa_port *dp; 62 + u16 vid; 63 + int err; 64 + 65 + err = mv88e6xxx_find_vid(chip, fid, &vid); 66 + if (err) 67 + return err; 68 + 69 + info.vid = vid; 70 + dp = dsa_to_port(chip->ds, port); 71 + 72 + rtnl_lock(); 73 + brport = dsa_port_to_bridge_port(dp); 74 + if (!brport) { 75 + rtnl_unlock(); 76 + return -ENODEV; 77 + } 78 + err = call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, 79 + brport, &info.info, NULL); 80 + rtnl_unlock(); 81 + 82 + return err; 83 + }
+19
drivers/net/dsa/mv88e6xxx/switchdev.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later 2 + * 3 + * switchdev.h 4 + * 5 + * Authors: 6 + * Hans J. Schultz <netdev@kapio-technology.com> 7 + * 8 + */ 9 + 10 + #ifndef _MV88E6XXX_SWITCHDEV_H_ 11 + #define _MV88E6XXX_SWITCHDEV_H_ 12 + 13 + #include "chip.h" 14 + 15 + int mv88e6xxx_handle_miss_violation(struct mv88e6xxx_chip *chip, int port, 16 + struct mv88e6xxx_atu_entry *entry, 17 + u16 fid); 18 + 19 + #endif /* _MV88E6XXX_SWITCHDEV_H_ */