diff options
author | Dave Jiang <dave.jiang@intel.com> | 2014-08-28 16:53:07 -0400 |
---|---|---|
committer | Jon Mason <jdmason@kudzu.us> | 2014-10-17 07:08:50 -0400 |
commit | b775e85bdb0395077a23bc072c4a62986883e276 (patch) | |
tree | d4d4a2074844d0949b4668f4422c6ee6ef4956e3 | |
parent | 6465d02ee15f7a45339b7e7859d0a0f22100ca87 (diff) |
ntb: move platform detection to separate function
Move the platform detection function to separate functions to allow
easier maintenence.
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r-- | drivers/ntb/ntb_hw.c | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c index a3990363a171..7567452250df 100644 --- a/drivers/ntb/ntb_hw.c +++ b/drivers/ntb/ntb_hw.c | |||
@@ -109,6 +109,41 @@ static const struct pci_device_id ntb_pci_tbl[] = { | |||
109 | }; | 109 | }; |
110 | MODULE_DEVICE_TABLE(pci, ntb_pci_tbl); | 110 | MODULE_DEVICE_TABLE(pci, ntb_pci_tbl); |
111 | 111 | ||
112 | static int is_ntb_xeon(struct ntb_device *ndev) | ||
113 | { | ||
114 | switch (ndev->pdev->device) { | ||
115 | case PCI_DEVICE_ID_INTEL_NTB_SS_JSF: | ||
116 | case PCI_DEVICE_ID_INTEL_NTB_SS_SNB: | ||
117 | case PCI_DEVICE_ID_INTEL_NTB_SS_IVT: | ||
118 | case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: | ||
119 | case PCI_DEVICE_ID_INTEL_NTB_PS_JSF: | ||
120 | case PCI_DEVICE_ID_INTEL_NTB_PS_SNB: | ||
121 | case PCI_DEVICE_ID_INTEL_NTB_PS_IVT: | ||
122 | case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: | ||
123 | case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF: | ||
124 | case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB: | ||
125 | case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT: | ||
126 | case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: | ||
127 | return 1; | ||
128 | default: | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static int is_ntb_atom(struct ntb_device *ndev) | ||
136 | { | ||
137 | switch (ndev->pdev->device) { | ||
138 | case PCI_DEVICE_ID_INTEL_NTB_B2B_BWD: | ||
139 | return 1; | ||
140 | default: | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
112 | /** | 147 | /** |
113 | * ntb_register_event_callback() - register event callback | 148 | * ntb_register_event_callback() - register event callback |
114 | * @ndev: pointer to ntb_device instance | 149 | * @ndev: pointer to ntb_device instance |
@@ -535,7 +570,7 @@ static void ntb_link_event(struct ntb_device *ndev, int link_state) | |||
535 | ndev->link_status = NTB_LINK_UP; | 570 | ndev->link_status = NTB_LINK_UP; |
536 | event = NTB_EVENT_HW_LINK_UP; | 571 | event = NTB_EVENT_HW_LINK_UP; |
537 | 572 | ||
538 | if (ndev->hw_type == BWD_HW || | 573 | if (is_ntb_atom(ndev) || |
539 | ndev->conn_type == NTB_CONN_TRANSPARENT) | 574 | ndev->conn_type == NTB_CONN_TRANSPARENT) |
540 | status = readw(ndev->reg_ofs.lnk_stat); | 575 | status = readw(ndev->reg_ofs.lnk_stat); |
541 | else { | 576 | else { |
@@ -566,7 +601,7 @@ static int ntb_link_status(struct ntb_device *ndev) | |||
566 | { | 601 | { |
567 | int link_state; | 602 | int link_state; |
568 | 603 | ||
569 | if (ndev->hw_type == BWD_HW) { | 604 | if (is_ntb_atom(ndev)) { |
570 | u32 ntb_cntl; | 605 | u32 ntb_cntl; |
571 | 606 | ||
572 | ntb_cntl = readl(ndev->reg_ofs.lnk_cntl); | 607 | ntb_cntl = readl(ndev->reg_ofs.lnk_cntl); |
@@ -932,27 +967,12 @@ static int ntb_device_setup(struct ntb_device *ndev) | |||
932 | { | 967 | { |
933 | int rc; | 968 | int rc; |
934 | 969 | ||
935 | switch (ndev->pdev->device) { | 970 | if (is_ntb_xeon(ndev)) |
936 | case PCI_DEVICE_ID_INTEL_NTB_SS_JSF: | ||
937 | case PCI_DEVICE_ID_INTEL_NTB_SS_SNB: | ||
938 | case PCI_DEVICE_ID_INTEL_NTB_SS_IVT: | ||
939 | case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: | ||
940 | case PCI_DEVICE_ID_INTEL_NTB_PS_JSF: | ||
941 | case PCI_DEVICE_ID_INTEL_NTB_PS_SNB: | ||
942 | case PCI_DEVICE_ID_INTEL_NTB_PS_IVT: | ||
943 | case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: | ||
944 | case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF: | ||
945 | case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB: | ||
946 | case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT: | ||
947 | case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: | ||
948 | rc = ntb_xeon_setup(ndev); | 971 | rc = ntb_xeon_setup(ndev); |
949 | break; | 972 | else if (is_ntb_atom(ndev)) |
950 | case PCI_DEVICE_ID_INTEL_NTB_B2B_BWD: | ||
951 | rc = ntb_bwd_setup(ndev); | 973 | rc = ntb_bwd_setup(ndev); |
952 | break; | 974 | else |
953 | default: | ||
954 | rc = -ENODEV; | 975 | rc = -ENODEV; |
955 | } | ||
956 | 976 | ||
957 | if (rc) | 977 | if (rc) |
958 | return rc; | 978 | return rc; |
@@ -970,7 +990,7 @@ static int ntb_device_setup(struct ntb_device *ndev) | |||
970 | 990 | ||
971 | static void ntb_device_free(struct ntb_device *ndev) | 991 | static void ntb_device_free(struct ntb_device *ndev) |
972 | { | 992 | { |
973 | if (ndev->hw_type == BWD_HW) { | 993 | if (is_ntb_atom(ndev)) { |
974 | cancel_delayed_work_sync(&ndev->hb_timer); | 994 | cancel_delayed_work_sync(&ndev->hb_timer); |
975 | cancel_delayed_work_sync(&ndev->lr_timer); | 995 | cancel_delayed_work_sync(&ndev->lr_timer); |
976 | } | 996 | } |
@@ -1050,7 +1070,7 @@ static irqreturn_t ntb_interrupt(int irq, void *dev) | |||
1050 | struct ntb_device *ndev = dev; | 1070 | struct ntb_device *ndev = dev; |
1051 | unsigned int i = 0; | 1071 | unsigned int i = 0; |
1052 | 1072 | ||
1053 | if (ndev->hw_type == BWD_HW) { | 1073 | if (is_ntb_atom(ndev)) { |
1054 | u64 ldb = readq(ndev->reg_ofs.ldb); | 1074 | u64 ldb = readq(ndev->reg_ofs.ldb); |
1055 | 1075 | ||
1056 | dev_dbg(&ndev->pdev->dev, "irq %d - ldb = %Lx\n", irq, ldb); | 1076 | dev_dbg(&ndev->pdev->dev, "irq %d - ldb = %Lx\n", irq, ldb); |
@@ -1192,7 +1212,7 @@ static int ntb_setup_msix(struct ntb_device *ndev) | |||
1192 | for (i = 0; i < msix_entries; i++) | 1212 | for (i = 0; i < msix_entries; i++) |
1193 | ndev->msix_entries[i].entry = i; | 1213 | ndev->msix_entries[i].entry = i; |
1194 | 1214 | ||
1195 | if (ndev->hw_type == BWD_HW) | 1215 | if (is_ntb_atom(ndev)) |
1196 | rc = ntb_setup_bwd_msix(ndev, msix_entries); | 1216 | rc = ntb_setup_bwd_msix(ndev, msix_entries); |
1197 | else | 1217 | else |
1198 | rc = ntb_setup_snb_msix(ndev, msix_entries); | 1218 | rc = ntb_setup_snb_msix(ndev, msix_entries); |
@@ -1252,7 +1272,7 @@ static int ntb_setup_interrupts(struct ntb_device *ndev) | |||
1252 | /* On BWD, disable all interrupts. On SNB, disable all but Link | 1272 | /* On BWD, disable all interrupts. On SNB, disable all but Link |
1253 | * Interrupt. The rest will be unmasked as callbacks are registered. | 1273 | * Interrupt. The rest will be unmasked as callbacks are registered. |
1254 | */ | 1274 | */ |
1255 | if (ndev->hw_type == BWD_HW) | 1275 | if (is_ntb_atom(ndev)) |
1256 | writeq(~0, ndev->reg_ofs.ldb_mask); | 1276 | writeq(~0, ndev->reg_ofs.ldb_mask); |
1257 | else { | 1277 | else { |
1258 | u16 var = 1 << SNB_LINK_DB; | 1278 | u16 var = 1 << SNB_LINK_DB; |
@@ -1285,7 +1305,7 @@ static void ntb_free_interrupts(struct ntb_device *ndev) | |||
1285 | struct pci_dev *pdev = ndev->pdev; | 1305 | struct pci_dev *pdev = ndev->pdev; |
1286 | 1306 | ||
1287 | /* mask interrupts */ | 1307 | /* mask interrupts */ |
1288 | if (ndev->hw_type == BWD_HW) | 1308 | if (is_ntb_atom(ndev)) |
1289 | writeq(~0, ndev->reg_ofs.ldb_mask); | 1309 | writeq(~0, ndev->reg_ofs.ldb_mask); |
1290 | else | 1310 | else |
1291 | writew(~0, ndev->reg_ofs.ldb_mask); | 1311 | writew(~0, ndev->reg_ofs.ldb_mask); |
@@ -1296,7 +1316,7 @@ static void ntb_free_interrupts(struct ntb_device *ndev) | |||
1296 | 1316 | ||
1297 | for (i = 0; i < ndev->num_msix; i++) { | 1317 | for (i = 0; i < ndev->num_msix; i++) { |
1298 | msix = &ndev->msix_entries[i]; | 1318 | msix = &ndev->msix_entries[i]; |
1299 | if (ndev->hw_type != BWD_HW && i == ndev->num_msix - 1) | 1319 | if (is_ntb_xeon(ndev) && i == ndev->num_msix - 1) |
1300 | free_irq(msix->vector, ndev); | 1320 | free_irq(msix->vector, ndev); |
1301 | else | 1321 | else |
1302 | free_irq(msix->vector, &ndev->db_cb[i]); | 1322 | free_irq(msix->vector, &ndev->db_cb[i]); |
@@ -1385,7 +1405,7 @@ static ssize_t ntb_debugfs_read(struct file *filp, char __user *ubuf, | |||
1385 | ndev->link_width); | 1405 | ndev->link_width); |
1386 | } | 1406 | } |
1387 | 1407 | ||
1388 | if (ndev->hw_type != BWD_HW) { | 1408 | if (is_ntb_xeon(ndev)) { |
1389 | u32 status32; | 1409 | u32 status32; |
1390 | u16 status16; | 1410 | u16 status16; |
1391 | int rc; | 1411 | int rc; |