diff mbox series

[V2,1/3] pm80xx : Support for get phy profile functionality.

Message ID 20200624120322.6265-2-deepak.ukey@microchip.com (mailing list archive)
State Superseded
Headers show
Series pm80xx : Updates for the driver version 0.1.39. | expand

Commit Message

Deepak Ukey June 24, 2020, 12:03 p.m. UTC
From: Viswas G <Viswas.G@microchip.com>

Added the support to get the phy profile which gives information
about the phy states, port and errors on phy.

Signed-off-by: Deepak Ukey <deepak.ukey@microchip.com>
Signed-off-by: Viswas G <Viswas.G@microchip.com>
Signed-off-by: Radha Ramachandran <radha@google.com>
---
 drivers/scsi/pm8001/pm8001_ctl.h  | 20 ++++++++++
 drivers/scsi/pm8001/pm8001_init.c |  2 +
 drivers/scsi/pm8001/pm8001_sas.h  |  5 +++
 drivers/scsi/pm8001/pm80xx_hwi.c  | 83 ++++++++++++++++++++++++++++++++++++++-
 drivers/scsi/pm8001/pm80xx_hwi.h  |  2 +
 5 files changed, 110 insertions(+), 2 deletions(-)

Comments

kernel test robot June 24, 2020, 2:18 p.m. UTC | #1
Hi Deepak,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next v5.8-rc2 next-20200624]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Deepak-Ukey/pm80xx-Updates-for-the-driver-version-0-1-39/20200624-195528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: x86_64-rhel-7.6 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/scsi/pm8001/pm80xx_hwi.c:69:6: warning: no previous prototype for 'pm80xx_pci_mem_copy' [-Wmissing-prototypes]
      69 | void pm80xx_pci_mem_copy(struct pm8001_hba_info  *pm8001_ha, u32 soffset,
         |      ^~~~~~~~~~~~~~~~~~~
>> drivers/scsi/pm8001/pm80xx_hwi.c:5064:5: warning: no previous prototype for 'pm8001_chip_get_phy_profile' [-Wmissing-prototypes]
    5064 | int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha, int phy_id,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/pm8001/pm80xx_hwi.c:5094:6: warning: no previous prototype for 'mpi_set_phy_profile_req' [-Wmissing-prototypes]
    5094 | void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha,
         |      ^~~~~~~~~~~~~~~~~~~~~~~

vim +/pm8001_chip_get_phy_profile +5064 drivers/scsi/pm8001/pm80xx_hwi.c

  5063	
> 5064	int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha, int phy_id,
  5065			int page_code, struct completion *comp, void *buf)
  5066	{
  5067		u32 tag;
  5068		struct get_phy_profile_req payload;
  5069		struct inbound_queue_table *circularQ;
  5070		struct pm8001_ccb_info *ccb;
  5071		int rc, ppc_phyid;
  5072		u32 opc = OPC_INB_GET_PHY_PROFILE;
  5073	
  5074		memset(&payload, 0, sizeof(payload));
  5075	
  5076		rc = pm8001_tag_alloc(pm8001_ha, &tag);
  5077		if (rc)
  5078			PM8001_FAIL_DBG(pm8001_ha, pm8001_printk("Invalid tag\n"));
  5079	
  5080		ccb = &pm8001_ha->ccb_info[tag];
  5081		ccb->completion = comp;
  5082		ccb->resp_buf = buf;
  5083		circularQ = &pm8001_ha->inbnd_q_tbl[0];
  5084	
  5085		payload.tag = cpu_to_le32(tag);
  5086		ppc_phyid = (page_code & 0xFF)  << 8 | (phy_id & 0xFF);
  5087		payload.ppc_phyid = cpu_to_le32(ppc_phyid);
  5088	
  5089		pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
  5090				sizeof(payload), 0);
  5091		return rc;
  5092	}
  5093	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot June 24, 2020, 3:40 p.m. UTC | #2
Hi Deepak,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next v5.8-rc2 next-20200624]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Deepak-Ukey/pm80xx-Updates-for-the-driver-version-0-1-39/20200624-195528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 1d4c87335d5236ea1f35937e1014980ba961ae34)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/scsi/pm8001/pm80xx_hwi.c:69:6: warning: no previous prototype for function 'pm80xx_pci_mem_copy' [-Wmissing-prototypes]
   void pm80xx_pci_mem_copy(struct pm8001_hba_info  *pm8001_ha, u32 soffset,
        ^
   drivers/scsi/pm8001/pm80xx_hwi.c:69:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void pm80xx_pci_mem_copy(struct pm8001_hba_info  *pm8001_ha, u32 soffset,
   ^
   static 
>> drivers/scsi/pm8001/pm80xx_hwi.c:5064:5: warning: no previous prototype for function 'pm8001_chip_get_phy_profile' [-Wmissing-prototypes]
   int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha, int phy_id,
       ^
   drivers/scsi/pm8001/pm80xx_hwi.c:5064:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha, int phy_id,
   ^
   static 
   drivers/scsi/pm8001/pm80xx_hwi.c:5094:6: warning: no previous prototype for function 'mpi_set_phy_profile_req' [-Wmissing-prototypes]
   void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha,
        ^
   drivers/scsi/pm8001/pm80xx_hwi.c:5094:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha,
   ^
   static 
   3 warnings generated.

vim +/pm8001_chip_get_phy_profile +5064 drivers/scsi/pm8001/pm80xx_hwi.c

  5063	
> 5064	int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha, int phy_id,
  5065			int page_code, struct completion *comp, void *buf)
  5066	{
  5067		u32 tag;
  5068		struct get_phy_profile_req payload;
  5069		struct inbound_queue_table *circularQ;
  5070		struct pm8001_ccb_info *ccb;
  5071		int rc, ppc_phyid;
  5072		u32 opc = OPC_INB_GET_PHY_PROFILE;
  5073	
  5074		memset(&payload, 0, sizeof(payload));
  5075	
  5076		rc = pm8001_tag_alloc(pm8001_ha, &tag);
  5077		if (rc)
  5078			PM8001_FAIL_DBG(pm8001_ha, pm8001_printk("Invalid tag\n"));
  5079	
  5080		ccb = &pm8001_ha->ccb_info[tag];
  5081		ccb->completion = comp;
  5082		ccb->resp_buf = buf;
  5083		circularQ = &pm8001_ha->inbnd_q_tbl[0];
  5084	
  5085		payload.tag = cpu_to_le32(tag);
  5086		ppc_phyid = (page_code & 0xFF)  << 8 | (phy_id & 0xFF);
  5087		payload.ppc_phyid = cpu_to_le32(ppc_phyid);
  5088	
  5089		pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
  5090				sizeof(payload), 0);
  5091		return rc;
  5092	}
  5093	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_ctl.h b/drivers/scsi/pm8001/pm8001_ctl.h
index d0d43a250b9e..02dc04a1fbe8 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.h
+++ b/drivers/scsi/pm8001/pm8001_ctl.h
@@ -41,6 +41,26 @@ 
 #ifndef PM8001_CTL_H_INCLUDED
 #define PM8001_CTL_H_INCLUDED
 
+struct phy_status {
+	char		phy_id;
+	unsigned int	phy_state:4;
+	unsigned int	nlr:4;
+	unsigned int	plr:4;
+	unsigned int	reserved1:12;
+	unsigned char	port_id;
+	unsigned int	prts:4;
+	unsigned int	reserved2:20;
+} __packed;
+
+struct phy_errcnt {
+	unsigned int	InvalidDword;
+	unsigned int	runningDisparityError;
+	unsigned int	codeViolation;
+	unsigned int	LossOfSyncDW;
+	unsigned int	phyResetProblem;
+	unsigned int	inboundCRCError;
+};
+
 #define IOCTL_BUF_SIZE		4096
 #define HEADER_LEN			28
 #define SIZE_OFFSET			16
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index a8f5344fdfda..38a65e1da823 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -397,6 +397,8 @@  static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
 		pm8001_ha->ccb_info[i].task = NULL;
 		pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
 		pm8001_ha->ccb_info[i].device = NULL;
+		pm8001_ha->ccb_info[i].completion = NULL;
+		pm8001_ha->ccb_info[i].resp_buf = NULL;
 		++pm8001_ha->tags_num;
 	}
 	pm8001_ha->flags = PM8001F_INIT_TIME;
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index ae7ba9b3c4bc..488af79dec47 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -56,6 +56,7 @@ 
 #include <scsi/sas_ata.h>
 #include <linux/atomic.h>
 #include "pm8001_defs.h"
+#include "pm8001_ctl.h"
 
 #define DRV_NAME		"pm80xx"
 #define DRV_VERSION		"0.1.39"
@@ -244,6 +245,8 @@  struct pm8001_dispatch {
 	int (*sas_diag_execute_req)(struct pm8001_hba_info *pm8001_ha,
 		u32 state);
 	int (*sas_re_init_req)(struct pm8001_hba_info *pm8001_ha);
+	int (*get_phy_profile_req)(struct pm8001_hba_info *pm8001_ha,
+		int phy, int page, struct completion *comp, void *buf);
 };
 
 struct pm8001_chip_info {
@@ -318,6 +321,8 @@  struct pm8001_ccb_info {
 	struct pm8001_prd	buf_prd[PM8001_MAX_DMA_SG];
 	struct fw_control_ex	*fw_control_context;
 	u8			open_retry;
+	struct completion	*completion;
+	void			*resp_buf;
 };
 
 struct mpi_mem {
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 4d205ebaee87..a909d00c6897 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -3792,7 +3792,6 @@  static int mpi_set_controller_config_resp(struct pm8001_hba_info *pm8001_ha,
 	PM8001_MSG_DBG(pm8001_ha, pm8001_printk(
 			"SET CONTROLLER RESP: status 0x%x qlfr_pgcd 0x%x\n",
 			status, err_qlfr_pgcd));
-
 	return 0;
 }
 
@@ -3818,9 +3817,58 @@  static int mpi_get_controller_config_resp(struct pm8001_hba_info *pm8001_ha,
 static int mpi_get_phy_profile_resp(struct pm8001_hba_info *pm8001_ha,
 			void *piomb)
 {
+	u32 tag, page_code;
+	struct phy_status *phy_status, *phy_stat;
+	struct phy_errcnt *phy_err, *phy_err_cnt;
+	struct pm8001_ccb_info *ccb;
+	struct get_phy_profile_resp *pPayload =
+		(struct get_phy_profile_resp *)(piomb + 4);
+	u32 status = le32_to_cpu(pPayload->status);
+
+	page_code = (u8)((pPayload->ppc_phyid & 0xFF00) >> 8);
+
 	PM8001_MSG_DBG(pm8001_ha,
-			pm8001_printk(" pm80xx_addition_functionality\n"));
+		pm8001_printk(" pm80xx_addition_functionality\n"));
+	if (status) {
+		/* status is FAILED */
+		PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
+			"mpiGetPhyProfileReq failed  with status 0x%08x\n",
+			status));
+	}
 
+	tag = le32_to_cpu(pPayload->tag);
+	ccb = &pm8001_ha->ccb_info[tag];
+	if (ccb->completion != NULL) {
+		if (status) {
+			/* signal fail status */
+			memset(&ccb->resp_buf, 0xff, sizeof(ccb->resp_buf));
+		} else if (page_code == SAS_PHY_GENERAL_STATUS_PAGE) {
+			phy_status = (struct phy_status *)ccb->resp_buf;
+			phy_stat =
+			(struct phy_status *)pPayload->ppc_specific_rsp;
+			phy_status->phy_id = le32_to_cpu(phy_stat->phy_id);
+			phy_status->phy_state =
+					le32_to_cpu(phy_stat->phy_state);
+			phy_status->plr = le32_to_cpu(phy_stat->plr);
+			phy_status->nlr = le32_to_cpu(phy_stat->nlr);
+			phy_status->port_id = le32_to_cpu(phy_stat->port_id);
+			phy_status->prts = le32_to_cpu(phy_stat->prts);
+		} else if (page_code == SAS_PHY_ERR_COUNTERS_PAGE) {
+			phy_err = (struct phy_errcnt *)ccb->resp_buf;
+			phy_err_cnt =
+			(struct phy_errcnt *)pPayload->ppc_specific_rsp;
+			phy_err->InvalidDword =
+			le32_to_cpu(phy_err_cnt->InvalidDword);
+			phy_err->runningDisparityError =
+			le32_to_cpu(phy_err_cnt->runningDisparityError);
+			phy_err->LossOfSyncDW =
+			le32_to_cpu(phy_err_cnt->LossOfSyncDW);
+			phy_err->phyResetProblem =
+			le32_to_cpu(phy_err_cnt->phyResetProblem);
+		}
+		complete(ccb->completion);
+	}
+	pm8001_tag_free(pm8001_ha, tag);
 	return 0;
 }
 
@@ -5013,6 +5061,36 @@  pm80xx_chip_isr(struct pm8001_hba_info *pm8001_ha, u8 vec)
 	return IRQ_HANDLED;
 }
 
+int pm8001_chip_get_phy_profile(struct pm8001_hba_info *pm8001_ha, int phy_id,
+		int page_code, struct completion *comp, void *buf)
+{
+	u32 tag;
+	struct get_phy_profile_req payload;
+	struct inbound_queue_table *circularQ;
+	struct pm8001_ccb_info *ccb;
+	int rc, ppc_phyid;
+	u32 opc = OPC_INB_GET_PHY_PROFILE;
+
+	memset(&payload, 0, sizeof(payload));
+
+	rc = pm8001_tag_alloc(pm8001_ha, &tag);
+	if (rc)
+		PM8001_FAIL_DBG(pm8001_ha, pm8001_printk("Invalid tag\n"));
+
+	ccb = &pm8001_ha->ccb_info[tag];
+	ccb->completion = comp;
+	ccb->resp_buf = buf;
+	circularQ = &pm8001_ha->inbnd_q_tbl[0];
+
+	payload.tag = cpu_to_le32(tag);
+	ppc_phyid = (page_code & 0xFF)  << 8 | (phy_id & 0xFF);
+	payload.ppc_phyid = cpu_to_le32(ppc_phyid);
+
+	pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload,
+			sizeof(payload), 0);
+	return rc;
+}
+
 void mpi_set_phy_profile_req(struct pm8001_hba_info *pm8001_ha,
 	u32 operation, u32 phyid, u32 length, u32 *buf)
 {
@@ -5113,4 +5191,5 @@  const struct pm8001_dispatch pm8001_80xx_dispatch = {
 	.set_nvmd_req		= pm8001_chip_set_nvmd_req,
 	.fw_flash_update_req	= pm8001_chip_fw_flash_update_req,
 	.set_dev_state_req	= pm8001_chip_set_dev_state_req,
+	.get_phy_profile_req	= pm8001_chip_get_phy_profile,
 };
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h
index 701951a0f715..b5119c5479da 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.h
+++ b/drivers/scsi/pm8001/pm80xx_hwi.h
@@ -175,7 +175,9 @@ 
 #define PHY_STOP_ERR_DEVICE_ATTACHED	0x1046
 
 /* phy_profile */
+#define SAS_PHY_ERR_COUNTERS_PAGE	0x01
 #define SAS_PHY_ANALOG_SETTINGS_PAGE	0x04
+#define SAS_PHY_GENERAL_STATUS_PAGE	0x05
 #define PHY_DWORD_LENGTH		0xC
 
 /* Thermal related */