Pārlūkot izejas kodu

qcacld-3.0: Add CNSS_BUS_EVENT event handler

CNSS platform will notify bus related event, and add related
handler in CLD driver.

Change-Id: I257f2e09c4fbefa6c4913eb7a7deba165a9b73ec
CRs-Fixed: 2922102
Lin Bai 4 gadi atpakaļ
vecāks
revīzija
732ea69682

+ 10 - 0
core/hdd/src/wlan_hdd_driver_ops.c

@@ -2093,6 +2093,16 @@ wlan_hdd_pld_uevent(struct device *dev, struct pld_uevent_data *event_data)
 		hdd_send_hang_data(hang_evt_data.hang_data,
 				   QDF_HANG_EVENT_DATA_SIZE);
 		break;
+	case PLD_BUS_EVENT:
+		hdd_debug("Bus event received");
+
+		/* Currently only link_down taken care.
+		 * Need to extend event buffer to define more bus info,
+		 * if need later.
+		 */
+		if (event_data->bus_data.etype == PLD_BUS_EVENT_PCIE_LINK_DOWN)
+			host_log_device_status(WLAN_STATUS_BUS_EXCEPTION);
+		break;
 	default:
 		/* other events intentionally not handled */
 		hdd_debug("Received uevent %d", event_data->uevent);

+ 21 - 0
core/pld/inc/pld_common.h

@@ -144,18 +144,35 @@ struct pld_platform_cap {
  * @PLD_FW_DOWN: firmware is down
  * @PLD_FW_CRASHED: firmware has crashed
  * @PLD_FW_RECOVERY_START: firmware is starting recovery
+ * @PLD_FW_HANG_EVENT: firmware update hang event
+ * @PLD_BUS_EVENT: update bus/link event
  */
 enum pld_uevent {
 	PLD_FW_DOWN,
 	PLD_FW_CRASHED,
 	PLD_FW_RECOVERY_START,
 	PLD_FW_HANG_EVENT,
+	PLD_BUS_EVENT,
+};
+
+/**
+ * enum pld_bus_event - PLD bus event types
+ * @PLD_BUS_EVENT_PCIE_LINK_DOWN: PCIe link is down
+ * @PLD_BUS_EVENT_INVALID: invalid event type
+ */
+
+enum pld_bus_event {
+	PLD_BUS_EVENT_PCIE_LINK_DOWN = 0,
+
+	PLD_BUS_EVENT_INVALID = 0xFFFF,
 };
 
 /**
  * struct pld_uevent_data - uevent status received from platform driver
  * @uevent: uevent type
  * @fw_down: FW down info
+ * @hang_data: FW hang data
+ * @bus_event: bus related data
  */
 struct pld_uevent_data {
 	enum pld_uevent uevent;
@@ -167,6 +184,10 @@ struct pld_uevent_data {
 			void *hang_event_data;
 			u16 hang_event_data_len;
 		} hang_data;
+		struct {
+			enum pld_bus_event etype;
+			void *event_data;
+		} bus_data;
 	};
 };
 

+ 44 - 4
core/pld/src/pld_pcie.c

@@ -266,6 +266,33 @@ out:
 	return;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+/**
+ * pld_bus_event_type_convert() - Convert enum cnss_bus_event_type
+ *		to enum pld_bus_event
+ * @etype: enum cnss_bus_event_type value
+ *
+ * This function will convert enum cnss_bus_event_type to
+ * enum pld_bus_event.
+ *
+ * Return: enum pld_bus_event
+ */
+static inline
+enum pld_bus_event pld_bus_event_type_convert(enum cnss_bus_event_type etype)
+{
+	enum pld_bus_event pld_etype = PLD_BUS_EVENT_INVALID;
+
+	switch (etype) {
+	case BUS_EVENT_PCI_LINK_DOWN:
+		pld_etype = PLD_BUS_EVENT_PCIE_LINK_DOWN;
+		break;
+	default:
+		break;
+	}
+
+	return pld_etype;
+}
+
 /**
  * pld_pcie_update_event() - update wlan driver status callback function
  * @pdev: PCIE device
@@ -274,9 +301,8 @@ out:
  * This function will be called when platform driver wants to update wlan
  * driver's status.
  *
- * Return: void
+ * Return: 0 for success, non zero for error code
  */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
 static int pld_pcie_update_event(struct pci_dev *pdev,
 				 struct cnss_uevent_data *uevent_data)
 {
@@ -299,14 +325,28 @@ static int pld_pcie_update_event(struct pci_dev *pdev,
 		data.hang_data.hang_event_data_len =
 					hang_event->hang_event_data_len;
 		break;
+	case CNSS_BUS_EVENT:
+	{
+		struct cnss_bus_event *bus_evt = uevent_data->data;
+
+		if (!bus_evt)
+			return -EINVAL;
+
+		data.uevent = PLD_BUS_EVENT;
+
+		/* Process uevent_data->data if any */
+		data.bus_data.etype =
+			pld_bus_event_type_convert(bus_evt->etype);
+		data.bus_data.event_data = bus_evt->event_data;
+		break;
+	}
 	default:
-		goto out;
+		return 0;
 	}
 
 	if (pld_context->ops->uevent)
 		pld_context->ops->uevent(&pdev->dev, &data);
 
-out:
 	return 0;
 }
 #endif