Commit 9085fd09859fafbde17380b93d317a13c23c39af

Authored by Roopa Prabhu
Committed by David S. Miller
1 parent 4562b2fe1e

enic: Add support for new fw devcmds for port profile handling

This patch introduces new fw devcmds for port profile handling.
These new commands are similar to the current fw commands for
port profile handling. The only difference being that the new
commands split the existing port profile handling devcmds into multiple
fw commands, giving the driver finer control over port profile operations.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 3 changed files with 111 additions and 49 deletions Side-by-side Diff

drivers/net/enic/vnic_dev.c
... ... @@ -786,48 +786,6 @@
786 786 return r;
787 787 }
788 788  
789   -int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err)
790   -{
791   - u64 a0 = 0, a1 = 0;
792   - int wait = 1000;
793   - int ret;
794   -
795   - *done = 0;
796   -
797   - ret = vnic_dev_cmd(vdev, CMD_INIT_STATUS, &a0, &a1, wait);
798   - if (ret)
799   - return ret;
800   -
801   - *done = (a0 == 0);
802   -
803   - *err = (a0 == 0) ? (int)a1:0;
804   -
805   - return 0;
806   -}
807   -
808   -int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len)
809   -{
810   - u64 a0, a1 = len;
811   - int wait = 1000;
812   - dma_addr_t prov_pa;
813   - void *prov_buf;
814   - int ret;
815   -
816   - prov_buf = pci_alloc_consistent(vdev->pdev, len, &prov_pa);
817   - if (!prov_buf)
818   - return -ENOMEM;
819   -
820   - memcpy(prov_buf, buf, len);
821   -
822   - a0 = prov_pa;
823   -
824   - ret = vnic_dev_cmd(vdev, CMD_INIT_PROV_INFO, &a0, &a1, wait);
825   -
826   - pci_free_consistent(vdev->pdev, len, prov_buf, prov_pa);
827   -
828   - return ret;
829   -}
830   -
831 789 int vnic_dev_deinit(struct vnic_dev *vdev)
832 790 {
833 791 u64 a0 = 0, a1 = 0;
... ... @@ -925,5 +883,62 @@
925 883 err_out:
926 884 vnic_dev_unregister(vdev);
927 885 return NULL;
  886 +}
  887 +
  888 +int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len)
  889 +{
  890 + u64 a0, a1 = len;
  891 + int wait = 1000;
  892 + dma_addr_t prov_pa;
  893 + void *prov_buf;
  894 + int ret;
  895 +
  896 + prov_buf = pci_alloc_consistent(vdev->pdev, len, &prov_pa);
  897 + if (!prov_buf)
  898 + return -ENOMEM;
  899 +
  900 + memcpy(prov_buf, buf, len);
  901 +
  902 + a0 = prov_pa;
  903 +
  904 + ret = vnic_dev_cmd(vdev, CMD_INIT_PROV_INFO2, &a0, &a1, wait);
  905 +
  906 + pci_free_consistent(vdev->pdev, len, prov_buf, prov_pa);
  907 +
  908 + return ret;
  909 +}
  910 +
  911 +int vnic_dev_enable2(struct vnic_dev *vdev, int active)
  912 +{
  913 + u64 a0, a1 = 0;
  914 + int wait = 1000;
  915 +
  916 + a0 = (active ? CMD_ENABLE2_ACTIVE : 0);
  917 +
  918 + return vnic_dev_cmd(vdev, CMD_ENABLE2, &a0, &a1, wait);
  919 +}
  920 +
  921 +static int vnic_dev_cmd_status(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
  922 + int *status)
  923 +{
  924 + u64 a0 = cmd, a1 = 0;
  925 + int wait = 1000;
  926 + int ret;
  927 +
  928 + ret = vnic_dev_cmd(vdev, CMD_STATUS, &a0, &a1, wait);
  929 + if (!ret)
  930 + *status = (int)a0;
  931 +
  932 + return ret;
  933 +}
  934 +
  935 +int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status)
  936 +{
  937 + return vnic_dev_cmd_status(vdev, CMD_ENABLE2, status);
  938 +}
  939 +
  940 +int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status)
  941 +{
  942 + return vnic_dev_cmd_status(vdev, CMD_DEINIT, status);
928 943 }
drivers/net/enic/vnic_dev.h
... ... @@ -108,8 +108,6 @@
108 108 int vnic_dev_open(struct vnic_dev *vdev, int arg);
109 109 int vnic_dev_open_done(struct vnic_dev *vdev, int *done);
110 110 int vnic_dev_init(struct vnic_dev *vdev, int arg);
111   -int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err);
112   -int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len);
113 111 int vnic_dev_deinit(struct vnic_dev *vdev);
114 112 int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg);
115 113 int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done);
... ... @@ -122,6 +120,10 @@
122 120 struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev,
123 121 void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar,
124 122 unsigned int num_bars);
  123 +int vnic_dev_init_prov2(struct vnic_dev *vdev, u8 *buf, u32 len);
  124 +int vnic_dev_enable2(struct vnic_dev *vdev, int active);
  125 +int vnic_dev_enable2_done(struct vnic_dev *vdev, int *status);
  126 +int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status);
125 127  
126 128 #endif /* _VNIC_DEV_H_ */
drivers/net/enic/vnic_devcmd.h
... ... @@ -267,17 +267,62 @@
267 267  
268 268 /*
269 269 * As for BY_BDF except a0 is index of hvnlink subordinate vnic
270   - * or SR-IOV virtual vnic */
  270 + * or SR-IOV virtual vnic
  271 + */
271 272 CMD_PROXY_BY_INDEX = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 43),
272 273  
273 274 /*
274   - * in: (u64)a0=paddr of buffer to put latest VIC VIF-CONFIG-INFO TLV in
275   - * (u32)a1=length of buffer in a0
276   - * out: (u64)a0=paddr of buffer with latest VIC VIF-CONFIG-INFO TLV
277   - * (u32)a1=actual length of latest VIC VIF-CONFIG-INFO TLV */
  275 + * For HPP toggle:
  276 + * adapter-info-get
  277 + * in: (u64)a0=phsical address of buffer passed in from caller.
  278 + * (u16)a1=size of buffer specified in a0.
  279 + * out: (u64)a0=phsical address of buffer passed in from caller.
  280 + * (u16)a1=actual bytes from VIF-CONFIG-INFO TLV, or
  281 + * 0 if no VIF-CONFIG-INFO TLV was ever received. */
278 282 CMD_CONFIG_INFO_GET = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
  283 +
  284 + /* init_prov_info2:
  285 + * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
  286 + * the vnic until CMD_ENABLE2 is issued.
  287 + * (u64)a0=paddr of vnic_devcmd_provinfo
  288 + * (u32)a1=sizeof provision info */
  289 + CMD_INIT_PROV_INFO2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
  290 +
  291 + /* enable2:
  292 + * (u32)a0=0 ==> standby
  293 + * =CMD_ENABLE2_ACTIVE ==> active
  294 + */
  295 + CMD_ENABLE2 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 48),
  296 +
  297 + /*
  298 + * cmd_status:
  299 + * Returns the status of the specified command
  300 + * Input:
  301 + * a0 = command for which status is being queried.
  302 + * Possible values are:
  303 + * CMD_SOFT_RESET
  304 + * CMD_HANG_RESET
  305 + * CMD_OPEN
  306 + * CMD_INIT
  307 + * CMD_INIT_PROV_INFO
  308 + * CMD_DEINIT
  309 + * CMD_INIT_PROV_INFO2
  310 + * CMD_ENABLE2
  311 + * Output:
  312 + * if status == STAT_ERROR
  313 + * a0 = ERR_ENOTSUPPORTED - status for command in a0 is
  314 + * not supported
  315 + * if status == STAT_NONE
  316 + * a0 = status of the devcmd specified in a0 as follows.
  317 + * ERR_SUCCESS - command in a0 completed successfully
  318 + * ERR_EINPROGRESS - command in a0 is still in progress
  319 + */
  320 + CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49),
279 321 };
280 322  
  323 +/* CMD_ENABLE2 flags */
  324 +#define CMD_ENABLE2_ACTIVE 0x1
  325 +
281 326 /* flags for CMD_OPEN */
282 327 #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */
283 328  
... ... @@ -315,6 +360,8 @@
315 360 ERR_ETIMEDOUT = 8,
316 361 ERR_ELINKDOWN = 9,
317 362 ERR_EMAXRES = 10,
  363 + ERR_ENOTSUPPORTED = 11,
  364 + ERR_EINPROGRESS = 12,
318 365 };
319 366  
320 367 /*