Hi Mikulėnas, On Tue, Nov 16, 2021, 3:12 AM Mantas Mikulėnas <graw...@gmail.com> wrote:
> Most of this looks like it could be done with systemd-networkd to create a > bond .netdev, with a small oneshot service for i2c. (What's the exact > criteria for when it should be run? Does it depend on bond0 being there, > does it need to be last, etc?) > It can be last in the startup chain I guess, don't know what other systemd things that might need the network to be up before the last unit file runs. I start linuxptp too so I would have the unit file that starts ptp4l start after the bond was created etc. Same thing for the i2c command to enable the switch. Regards, Brian > On Tue, Nov 16, 2021, 02:58 Brian Hutchinson <b.hutch...@gmail.com> wrote: > >> Hi, >> >> I'm on a IMX8 platform and have a Microchip KSZ9567 Ethernet switch. I >> can use IP commands to manually bring lan1 and lan2 interfaces up and then >> create a redundant/failover bond ... but I'm having difficulty figuring out >> how to do this the "systemd" way. >> >> My first attempt was to just have systemd run a script of all the >> commands I do manually but during system startup there appears to be race >> conditions so I have to set my service type to "Idle" and sometimes even >> that doesn't work. So I want to exploit any systemd support for DSA and >> bonding. >> >> Here is script my manual steps which is what I want systemd to ultimately >> do: >> >> #!/bin/bash >> >> # Create a redundant bond between ksz9567 DSA lan1 and lan2 interfaces >> >> # Load bonding kernel module >> modprobe bonding >> >> # Bring up CPU interface (cpu to switch port 7 - the RGMII link) >> ip link set eth0 up >> >> # Create a bond >> echo +bond0 > /sys/class/net/bonding_masters >> >> # Set mode to active-backup (redundancy failover) >> echo active-backup > /sys/class/net/bond0/bonding/mode >> >> # Set time it takes (in ms) for slave to move when a link goes down >> echo 1000 > /sys/class/net/bond0/bonding/miimon >> >> # Add slaves to bond >> >> echo +lan1 > /sys/class/net/bond0/bonding/slaves >> echo +lan2 > /sys/class/net/bond0/bonding/slaves >> >> # Set IP and netmask of the bond >> ip addr add 192.168.0.4/24 dev bond0 >> >> # And bring bond up. Pings and network connectivity should work now >> ip link set bond0 up >> >> # For a board that doesn't have Ethernet switch hardware strapped to >> enable at boot .. enable it now >> i2cset -f -y 0 0x5f 0x03 0x00 0x01 i >> >> Thanks for any information, pointers etc. >> >> Regards, >> >> Brian >> >