Thu Dec 5 05:29:28 2019 UTC ()
Fix previous comment change for ifm_media. It was correct.

 The real problem is that some driver misuse ifm_media as the current active
media. struct mii_data has the current active media(mii_media_active). If a
driver use mii(4), it can be use mii->mii_media_active for this purpose.
struct ifmedia has no entry for this purpose. Some drivers have an entry
in their own softc to keep the value, but some other's don't have it and
they mistakenly use ifm_media.

 We might add a new entry to struct ifmedia in future to avoid this confusion
and for simplify.


(msaitoh)
diff -r1.67 -r1.68 src/sys/net/if_media.h

cvs diff -r1.67 -r1.68 src/sys/net/if_media.h (expand / switch to unified diff)

--- src/sys/net/if_media.h 2019/11/28 14:08:22 1.67
+++ src/sys/net/if_media.h 2019/12/05 05:29:27 1.68
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_media.h,v 1.67 2019/11/28 14:08:22 msaitoh Exp $ */ 1/* $NetBSD: if_media.h,v 1.68 2019/12/05 05:29:27 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -873,28 +873,35 @@ typedef void (*ifm_stat_cb_t)(struct ifn @@ -873,28 +873,35 @@ typedef void (*ifm_stat_cb_t)(struct ifn
873struct ifmedia_entry { 873struct ifmedia_entry {
874 TAILQ_ENTRY(ifmedia_entry) ifm_list; 874 TAILQ_ENTRY(ifmedia_entry) ifm_list;
875 u_int ifm_media; /* IFMWD: description of this media */ 875 u_int ifm_media; /* IFMWD: description of this media */
876 u_int ifm_data; /* for driver-specific use */ 876 u_int ifm_data; /* for driver-specific use */
877 void *ifm_aux; /* for driver-specific use */ 877 void *ifm_aux; /* for driver-specific use */
878}; 878};
879 879
880/* 880/*
881 * One of these goes into a network interface's softc structure. 881 * One of these goes into a network interface's softc structure.
882 * It is used to keep general media state. 882 * It is used to keep general media state.
883 */ 883 */
884struct ifmedia { 884struct ifmedia {
885 u_int ifm_mask; /* IFMWD: mask of changes we don't care */ 885 u_int ifm_mask; /* IFMWD: mask of changes we don't care */
886 u_int ifm_media; /* IFMWD: current active media word */ 886 u_int ifm_media; /*
887 struct ifmedia_entry *ifm_cur; /* current user-selected media */ 887 * IFMWD: current use-set media word.
 888 *
 889 * XXX some drivers misuse this entry as
 890 * current active media word. Don't use this
 891 * entry as this purpose but use driver
 892 * specific entry if you don't use mii(4).
 893 */
 894 struct ifmedia_entry *ifm_cur; /* current user-selected media entry */
888 TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */ 895 TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
889 ifm_change_cb_t ifm_change; /* media change driver callback */ 896 ifm_change_cb_t ifm_change; /* media change driver callback */
890 ifm_stat_cb_t ifm_status; /* media status driver callback */ 897 ifm_stat_cb_t ifm_status; /* media status driver callback */
891}; 898};
892 899
893/* Initialize an interface's struct if_media field. */ 900/* Initialize an interface's struct if_media field. */
894void ifmedia_init(struct ifmedia *, int, ifm_change_cb_t, ifm_stat_cb_t); 901void ifmedia_init(struct ifmedia *, int, ifm_change_cb_t, ifm_stat_cb_t);
895 902
896int ifmedia_change(struct ifmedia *, struct ifnet *); 903int ifmedia_change(struct ifmedia *, struct ifnet *);
897 904
898/* Add one supported medium to a struct ifmedia. */ 905/* Add one supported medium to a struct ifmedia. */
899void ifmedia_add(struct ifmedia *, int, int, void *); 906void ifmedia_add(struct ifmedia *, int, int, void *);
900 907