@@ -757,6 +757,39 @@ static enum ethernet_hw_caps eth_enc28j60_get_capabilities(const struct device *
757
757
;
758
758
}
759
759
760
+ static int eth_enc28j60_set_config (const struct device * dev ,
761
+ enum ethernet_config_type type ,
762
+ const struct ethernet_config * config )
763
+ {
764
+ struct eth_enc28j60_runtime * context = dev -> data ;
765
+
766
+ /* Compile time check that the memcpy below won't overflow */
767
+ BUILD_ASSERT (sizeof (context -> mac_address ) <= sizeof (config -> mac_address .addr ),
768
+ "ENC28j60 Runtime MAC address buffer too small" );
769
+
770
+ if (type == ETHERNET_CONFIG_TYPE_MAC_ADDRESS ) {
771
+ memcpy (context -> mac_address , config -> mac_address .addr ,
772
+ sizeof (config -> mac_address .addr ));
773
+ eth_enc28j60_init_mac (dev );
774
+
775
+ if (context -> iface != NULL ) {
776
+ net_if_set_link_addr (context -> iface , context -> mac_address ,
777
+ sizeof (context -> mac_address ),
778
+ NET_LINK_ETHERNET );
779
+ }
780
+
781
+ LOG_INF ("Set cfg - MAC %02x:%02x:%02x:%02x:%02x:%02x" ,
782
+ context -> mac_address [0 ], context -> mac_address [1 ],
783
+ context -> mac_address [2 ], context -> mac_address [3 ],
784
+ context -> mac_address [4 ], context -> mac_address [5 ]);
785
+
786
+ return 0 ;
787
+ }
788
+
789
+ /* Only mac address config supported */
790
+ return - ENOTSUP ;
791
+ }
792
+
760
793
static void eth_enc28j60_iface_init (struct net_if * iface )
761
794
{
762
795
const struct device * dev = net_if_get_device (iface );
@@ -783,7 +816,7 @@ static void eth_enc28j60_iface_init(struct net_if *iface)
783
816
784
817
static const struct ethernet_api api_funcs = {
785
818
.iface_api .init = eth_enc28j60_iface_init ,
786
-
819
+ . set_config = eth_enc28j60_set_config ,
787
820
.get_capabilities = eth_enc28j60_get_capabilities ,
788
821
.send = eth_enc28j60_tx ,
789
822
};
0 commit comments