Skip to contentSkip to conversation

ice: use GNSS subsystem instead of TTY

PATCH Superseded Arkadiusz Kubalewski 3 participants 4 messages Oct 19, 2022 – Nov 9, 2022

Subsystems (4)

v8 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v8 1/1 ice: use GNSS subsystem instead of TTY

Previously support for GNSS was implemented as a TTY driver, it allowed to access GNSS receiver on /dev/ttyGNSS_<bus><func>.

Use generic GNSS subsystem API instead of implementing own TTY driver. The receiver is accessible on /dev/gnss<id>. In case of multiple receivers in the OS, correct device can be found by enumerating either:
- /sys/class/net/<eth port>/device/gnss/
- /sys/class/gnss/gnss<id>/device/

User expecting onboard GNSS receiver support is required to enable CONFIG_GNSS=y/m in kernel config.

---
v8:
- fix example path to gnss device in commit message

v7:
- add blank lines around 'GNSS module' paragraph in ice.rst
- mark '/dev/gnss<id>' as a code in ice.rst

v6:
- enable support for CONFIG_GNSS=m
- improve commit message

v5:
- fix "ifeq" in Makefile (wrong usage of string)
- fix description in "#endif" to IS_BUILDIN

v4: change Makefile to build ice_gnss.c only if CONFIG_GNSS is set

v3:
- remove unnecessary #include,
- change the IS_ENABLED to IS_BUILTIN - right now if GNSS kernel subsystem is not enabled, we also won't enable it in our ice driver.

v2: fix sparse check warning, remove fixes tags, fix commit title

 .../device_drivers/ethernet/intel/ice.rst     |  16 +-
 drivers/net/ethernet/intel/ice/Makefile       |   5 +-
 drivers/net/ethernet/intel/ice/ice.h          |   6 +-
 drivers/net/ethernet/intel/ice/ice_gnss.c     | 380 +++++++-----------
 drivers/net/ethernet/intel/ice/ice_gnss.h     |  18 +-
 5 files changed, 167 insertions(+), 258 deletions(-)
Documentation/networking/device_drivers/ethernet/intel/ice.rst +9 -7
index dc2e60ced927..1aa029d08cb1 100644
@@ -901,15 +901,17 @@ To enable/disable UDP Segmentation Offload, issue the following command::
 
   # ethtool -K <ethX> tx-udp-segmentation [off|on]
 
+
 GNSS module
 -----------
-Allows user to read messages from the GNSS module and write supported commands.
-If the module is physically present, driver creates 2 TTYs for each supported
-device in /dev, ttyGNSS_<device>:<function>_0 and _1. First one (_0) is RW and
-the second one is RO.
-The protocol of write commands is dependent on the GNSS module as the driver
-writes raw bytes from the TTY to the GNSS i2c. Please refer to the module
-documentation for details.
+Requires kernel compiled with CONFIG_GNSS=y or CONFIG_GNSS=m.
+Allows user to read messages from the GNSS hardware module and write supported
+commands. If the module is physically present, a GNSS device is spawned:
+``/dev/gnss<id>``.
+The protocol of write command is dependent on the GNSS hardware module as the
+driver writes raw bytes by the GNSS object to the receiver through i2c. Please
+refer to the hardware GNSS module documentation for configuration details.
+
 
 Performance Optimization
 ========================
drivers/net/ethernet/intel/ice/Makefile +4 -1
index 9183d480b70b..7bc5ba52e493 100644
@@ -42,8 +42,11 @@ ice-$(CONFIG_PCI_IOV) +=	\
 	ice_vf_vsi_vlan_ops.o	\
 	ice_vf_lib.o
 ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
-ice-$(CONFIG_TTY) += ice_gnss.o
 ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
 ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
 ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
 ice-$(CONFIG_ICE_SWITCHDEV) += ice_eswitch.o
+ice-$(CONFIG_GNSS) += ice_gnss.o
+ifeq ($(CONFIG_GNSS), "m")
+	ice-y += ice_gnss.o
+endif
drivers/net/ethernet/intel/ice/ice.h +3 -3
index 001500afc4a6..de6763206113 100644
@@ -39,6 +39,7 @@
 #include <linux/avf/virtchnl.h>
 #include <linux/cpu_rmap.h>
 #include <linux/dim.h>
+#include <linux/gnss.h>
 #include <net/pkt_cls.h>
 #include <net/tc_act/tc_mirred.h>
 #include <net/tc_act/tc_gact.h>
@@ -543,9 +544,8 @@ struct ice_pf {
 	struct mutex adev_mutex;	/* lock to protect aux device access */
 	u32 msg_enable;
 	struct ice_ptp ptp;
-	struct tty_driver *ice_gnss_tty_driver;
-	struct tty_port *gnss_tty_port[ICE_GNSS_TTY_MINOR_DEVICES];
-	struct gnss_serial *gnss_serial[ICE_GNSS_TTY_MINOR_DEVICES];
+	struct gnss_serial *gnss_serial;
+	struct gnss_device *gnss_dev;
 	u16 num_rdma_msix;		/* Total MSIX vectors for RDMA driver */
 	u16 rdma_base_vector;
 
drivers/net/ethernet/intel/ice/ice_gnss.c +149 -231

553 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_gnss.h +2 -16
index f454dd1d9285..4d49e5b0b4b8 100644
@@ -4,15 +4,8 @@
 #ifndef _ICE_GNSS_H_
 #define _ICE_GNSS_H_
 
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-
 #define ICE_E810T_GNSS_I2C_BUS		0x2
 #define ICE_GNSS_TIMER_DELAY_TIME	(HZ / 10) /* 0.1 second per message */
-/* Create 2 minor devices, both using the same GNSS module. First one is RW,
- * second one RO.
- */
-#define ICE_GNSS_TTY_MINOR_DEVICES	2
 #define ICE_GNSS_TTY_WRITE_BUF		250
 #define ICE_MAX_I2C_DATA_SIZE		FIELD_MAX(ICE_AQC_I2C_DATA_SIZE_M)
 #define ICE_MAX_I2C_WRITE_BYTES		4
@@ -36,13 +29,9 @@ struct gnss_write_buf {
 	unsigned char *buf;
 };
 
-
 /**
  * struct gnss_serial - data used to initialize GNSS TTY port
  * @back: back pointer to PF
- * @tty: pointer to the tty for this device
- * @open_count: number of times this port has been opened
- * @gnss_mutex: gnss_mutex used to protect GNSS serial operations
  * @kworker: kwork thread for handling periodic work
  * @read_work: read_work function for handling GNSS reads
  * @write_work: write_work function for handling GNSS writes
@@ -50,16 +39,13 @@ struct gnss_write_buf {
  */
 struct gnss_serial {
 	struct ice_pf *back;
-	struct tty_struct *tty;
-	int open_count;
-	struct mutex gnss_mutex; /* protects GNSS serial structure */
 	struct kthread_worker *kworker;
 	struct kthread_delayed_work read_work;
 	struct kthread_work write_work;
 	struct list_head queue;
 };
 
-#if IS_ENABLED(CONFIG_TTY)
+#if IS_ENABLED(CONFIG_GNSS)
 void ice_gnss_init(struct ice_pf *pf);
 void ice_gnss_exit(struct ice_pf *pf);
 bool ice_gnss_is_gps_present(struct ice_hw *hw);
@@ -70,5 +56,5 @@ static inline bool ice_gnss_is_gps_present(struct ice_hw *hw)
 {
 	return false;
 }
-#endif /* IS_ENABLED(CONFIG_TTY) */
+#endif /* IS_ENABLED(CONFIG_GNSS) */
 #endif /* _ICE_GNSS_H_ */
Signature · 6 lines
2.34.3

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tested-by on v8 1/1
#1 lore raw
Quoted 50 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Arkadiusz Kubalewski
Sent: Wednesday, October 19, 2022 3:26 PM
To: [email protected]
Cc: Kolacinski, Karol <[email protected]>
Subject: [Intel-wired-lan] [PATCH next v8] ice: use GNSS subsystem instead of TTY

Previously support for GNSS was implemented as a TTY driver, it allowed to access GNSS receiver on /dev/ttyGNSS_<bus><func>.

Use generic GNSS subsystem API instead of implementing own TTY driver. The receiver is accessible on /dev/gnss<id>. In case of multiple receivers in the OS, correct device can be found by enumerating either:
- /sys/class/net/<eth port>/device/gnss/
- /sys/class/gnss/gnss<id>/device/

User expecting onboard GNSS receiver support is required to enable CONFIG_GNSS=y/m in kernel config.

---
v8:
- fix example path to gnss device in commit message

v7:
- add blank lines around 'GNSS module' paragraph in ice.rst
- mark '/dev/gnss<id>' as a code in ice.rst

v6:
- enable support for CONFIG_GNSS=m
- improve commit message

v5:
- fix "ifeq" in Makefile (wrong usage of string)
- fix description in "#endif" to IS_BUILDIN

v4: change Makefile to build ice_gnss.c only if CONFIG_GNSS is set

v3:
- remove unnecessary #include,
- change the IS_ENABLED to IS_BUILTIN - right now if GNSS kernel subsystem is not enabled, we also won't enable it in our ice driver.

Quoted 9 lines

v2: fix sparse check warning, remove fixes tags, fix commit title

 .../device_drivers/ethernet/intel/ice.rst     |  16 +-
 drivers/net/ethernet/intel/ice/Makefile       |   5 +-
 drivers/net/ethernet/intel/ice/ice.h          |   6 +-
 drivers/net/ethernet/intel/ice/ice_gnss.c     | 380 +++++++-----------
 drivers/net/ethernet/intel/ice/ice_gnss.h     |  18 +-
 5 files changed, 167 insertions(+), 258 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
In reply to Arkadiusz Kubalewski

From: Arkadiusz Kubalewski <[email protected]>
Date: Wed, 19 Oct 2022 11:56:03 +0200

Quoted 47 lines

Previously support for GNSS was implemented as a TTY driver, it allowed to access GNSS receiver on /dev/ttyGNSS_<bus><func>.

Use generic GNSS subsystem API instead of implementing own TTY driver. The receiver is accessible on /dev/gnss<id>. In case of multiple receivers in the OS, correct device can be found by enumerating either:
- /sys/class/net/<eth port>/device/gnss/
- /sys/class/gnss/gnss<id>/device/

User expecting onboard GNSS receiver support is required to enable CONFIG_GNSS=y/m in kernel config.

---
v8:
- fix example path to gnss device in commit message

v7:
- add blank lines around 'GNSS module' paragraph in ice.rst
- mark '/dev/gnss<id>' as a code in ice.rst

v6:
- enable support for CONFIG_GNSS=m
- improve commit message

v5:
- fix "ifeq" in Makefile (wrong usage of string)
- fix description in "#endif" to IS_BUILDIN

v4: change Makefile to build ice_gnss.c only if CONFIG_GNSS is set

v3:
- remove unnecessary #include,
- change the IS_ENABLED to IS_BUILTIN - right now if GNSS kernel subsystem is not enabled, we also won't enable it in our ice driver.

v2: fix sparse check warning, remove fixes tags, fix commit title

 .../device_drivers/ethernet/intel/ice.rst     |  16 +-
 drivers/net/ethernet/intel/ice/Makefile       |   5 +-
 drivers/net/ethernet/intel/ice/ice.h          |   6 +-
 drivers/net/ethernet/intel/ice/ice_gnss.c     | 380 +++++++-----------
 drivers/net/ethernet/intel/ice/ice_gnss.h     |  18 +-
 5 files changed, 167 insertions(+), 258 deletions(-)

[...]

Quoted 7 lines
drivers/net/ethernet/intel/ice/Makefile +0 -0
index 9183d480b70b..7bc5ba52e493 100644
@@ -42,8 +42,11 @@ ice-$(CONFIG_PCI_IOV) +=	\
 	ice_vf_vsi_vlan_ops.o	\
 	ice_vf_lib.o

drivers/net/ethernet/intel/ice/Makefile ice-$(CONFIG_PCI_IOV) += \ · line 52

Quoted 10 lines
drivers/net/ethernet/intel/ice/Makefile +4 -1
 ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
-ice-$(CONFIG_TTY) += ice_gnss.o
 ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
 ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
 ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
 ice-$(CONFIG_ICE_SWITCHDEV) += ice_eswitch.o
+ice-$(CONFIG_GNSS) += ice_gnss.o
+ifeq ($(CONFIG_GNSS), "m")
+	ice-y += ice_gnss.o
+endif

That looks weird.

First of all, Kbuild looks at both foo-y and foo-m when building a list of objects for a particular composite (in our case, ice.{,k}o is a composite and ice_gnss.o is a part of it) [0]. So just

ice-$(CONFIG_GNSS) += ice_gnss.o

would be enough.

But I would avoid those IS_REACHABLE() all around the code. In fact, you don't need to build this file when the GNSS framework is not usable from ice. So, instead I'd go for

(Kconfig)

config ICE_GNSS

	def_bool GNSS = y || GNSS = ICE

(Makefile)

ice-$(ICE_GNSS) += ice_gnss.o

ice_gnss.o will be then built only if GNSS is reachable and we can safely call its functions without any IS_REACHABLE() guards.

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice.h +0 -0
index 001500afc4a6..de6763206113 100644

[...]

Quoted 2 lines
Signature · 1 line
2.34.3

Thanks,
Olek
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw
Quoted 99 lines

-----Original Message-----
From: Lobakin, Alexandr <[email protected]>
Sent: Friday, October 28, 2022 6:57 PM
To: Kubalewski, Arkadiusz <[email protected]>
Cc: Lobakin, Alexandr <[email protected]>; Kolacinski, Karol <[email protected]>; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH next v8] ice: use GNSS subsystem instead of TTY

From: Arkadiusz Kubalewski <[email protected]>
Date: Wed, 19 Oct 2022 11:56:03 +0200

Quoted 32 lines

Previously support for GNSS was implemented as a TTY driver, it allowed to access GNSS receiver on /dev/ttyGNSS_<bus><func>.

Use generic GNSS subsystem API instead of implementing own TTY driver. The receiver is accessible on /dev/gnss<id>. In case of multiple receivers in the OS, correct device can be found by enumerating either:
- /sys/class/net/<eth port>/device/gnss/
- /sys/class/gnss/gnss<id>/device/

User expecting onboard GNSS receiver support is required to enable CONFIG_GNSS=y/m in kernel config.

---
v8:
- fix example path to gnss device in commit message

v7:
- add blank lines around 'GNSS module' paragraph in ice.rst
- mark '/dev/gnss<id>' as a code in ice.rst

v6:
- enable support for CONFIG_GNSS=m
- improve commit message

v5:
- fix "ifeq" in Makefile (wrong usage of string)
- fix description in "#endif" to IS_BUILDIN

Quoted 5 lines

v4: change Makefile to build ice_gnss.c only if CONFIG_GNSS is set

v3:
- remove unnecessary #include,
- change the IS_ENABLED to IS_BUILTIN - right now if GNSS kernel

subsystem

Quoted 10 lines

is not enabled, we also won't enable it in our ice driver.

v2: fix sparse check warning, remove fixes tags, fix commit title

 .../device_drivers/ethernet/intel/ice.rst     |  16 +-
 drivers/net/ethernet/intel/ice/Makefile       |   5 +-
 drivers/net/ethernet/intel/ice/ice.h          |   6 +-
 drivers/net/ethernet/intel/ice/ice_gnss.c     | 380 +++++++-----------
 drivers/net/ethernet/intel/ice/ice_gnss.h     |  18 +-
 5 files changed, 167 insertions(+), 258 deletions(-)

[...]

Quoted 8 lines
drivers/net/ethernet/intel/ice/Makefile +0 -0
index 9183d480b70b..7bc5ba52e493 100644
@@ -42,8 +42,11 @@ ice-$(CONFIG_PCI_IOV) +=	\
 	ice_vf_vsi_vlan_ops.o	\
 	ice_vf_lib.o

drivers/net/ethernet/intel/ice/Makefile ice-$(CONFIG_PCI_IOV) += \ · line 52

Quoted 10 lines
drivers/net/ethernet/intel/ice/Makefile +4 -1
 ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
-ice-$(CONFIG_TTY) += ice_gnss.o
 ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
 ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
 ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
 ice-$(CONFIG_ICE_SWITCHDEV) += ice_eswitch.o
+ice-$(CONFIG_GNSS) += ice_gnss.o
+ifeq ($(CONFIG_GNSS), "m")
+	ice-y += ice_gnss.o
+endif

That looks weird.

First of all, Kbuild looks at both foo-y and foo-m when building a list of objects for a particular composite (in our case, ice.{,k}o is a composite and ice_gnss.o is a part of it) [0]. So just

ice-$(CONFIG_GNSS) += ice_gnss.o

would be enough.

But I would avoid those IS_REACHABLE() all around the code. In fact, you don't need to build this file when the GNSS framework is not usable from ice. So, instead I'd go for

(Kconfig)

config ICE_GNSS

Quoted 9 lines
	def_bool GNSS = y || GNSS = ICE

(Makefile)

ice-$(ICE_GNSS) += ice_gnss.o

ice_gnss.o will be then built only if GNSS is reachable and we can safely call its functions without any IS_REACHABLE() guards.

Many thanks!
Fixed in v9.

BR, Arkadiusz

Quoted 8 lines
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice.h +0 -0
index 001500afc4a6..de6763206113 100644

[...]

Quoted 5 lines
Quoted 2 lines

--
2.34.3

Thanks,
Olek

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan