~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/enic/vnic_dev.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
408
408
                if (!vdev->fw_info)
409
409
                        return -ENOMEM;
410
410
 
 
411
                memset(vdev->fw_info, 0, sizeof(struct vnic_devcmd_fw_info));
 
412
 
411
413
                a0 = vdev->fw_info_pa;
 
414
                a1 = sizeof(struct vnic_devcmd_fw_info);
412
415
 
413
416
                /* only get fw_info once and cache it */
414
417
                err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait);
 
418
                if (err == ERR_ECMDUNKNOWN) {
 
419
                        err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO_OLD,
 
420
                                &a0, &a1, wait);
 
421
                }
415
422
        }
416
423
 
417
424
        *fw_info = vdev->fw_info;
419
426
        return err;
420
427
}
421
428
 
422
 
int vnic_dev_hw_version(struct vnic_dev *vdev, enum vnic_dev_hw_version *hw_ver)
423
 
{
424
 
        struct vnic_devcmd_fw_info *fw_info;
425
 
        int err;
426
 
 
427
 
        err = vnic_dev_fw_info(vdev, &fw_info);
428
 
        if (err)
429
 
                return err;
430
 
 
431
 
        if (strncmp(fw_info->hw_version, "A1", sizeof("A1")) == 0)
432
 
                *hw_ver = VNIC_DEV_HW_VER_A1;
433
 
        else if (strncmp(fw_info->hw_version, "A2", sizeof("A2")) == 0)
434
 
                *hw_ver = VNIC_DEV_HW_VER_A2;
435
 
        else
436
 
                *hw_ver = VNIC_DEV_HW_VER_UNKNOWN;
437
 
 
438
 
        return 0;
439
 
}
440
 
 
441
429
int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size,
442
430
        void *value)
443
431
{
798
786
        return r;
799
787
}
800
788
 
801
 
int vnic_dev_init_done(struct vnic_dev *vdev, int *done, int *err)
802
 
{
803
 
        u64 a0 = 0, a1 = 0;
804
 
        int wait = 1000;
805
 
        int ret;
806
 
 
807
 
        *done = 0;
808
 
 
809
 
        ret = vnic_dev_cmd(vdev, CMD_INIT_STATUS, &a0, &a1, wait);
810
 
        if (ret)
811
 
                return ret;
812
 
 
813
 
        *done = (a0 == 0);
814
 
 
815
 
        *err = (a0 == 0) ? (int)a1:0;
816
 
 
817
 
        return 0;
818
 
}
819
 
 
820
 
int vnic_dev_init_prov(struct vnic_dev *vdev, u8 *buf, u32 len)
821
 
{
822
 
        u64 a0, a1 = len;
823
 
        int wait = 1000;
824
 
        dma_addr_t prov_pa;
825
 
        void *prov_buf;
826
 
        int ret;
827
 
 
828
 
        prov_buf = pci_alloc_consistent(vdev->pdev, len, &prov_pa);
829
 
        if (!prov_buf)
830
 
                return -ENOMEM;
831
 
 
832
 
        memcpy(prov_buf, buf, len);
833
 
 
834
 
        a0 = prov_pa;
835
 
 
836
 
        ret = vnic_dev_cmd(vdev, CMD_INIT_PROV_INFO, &a0, &a1, wait);
837
 
 
838
 
        pci_free_consistent(vdev->pdev, len, prov_buf, prov_pa);
839
 
 
840
 
        return ret;
841
 
}
842
 
 
843
789
int vnic_dev_deinit(struct vnic_dev *vdev)
844
790
{
845
791
        u64 a0 = 0, a1 = 0;
939
885
        return NULL;
940
886
}
941
887
 
942
 
 
 
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);
 
943
}