|
17 | 17 |
|
18 | 18 | extern struct kmem_cache *idxd_desc_pool; |
19 | 19 |
|
20 | | -struct idxd_device; |
21 | 20 | struct idxd_wq; |
| 21 | +struct idxd_dev; |
| 22 | + |
| 23 | +enum idxd_dev_type { |
| 24 | + IDXD_DEV_NONE = -1, |
| 25 | + IDXD_DEV_DSA = 0, |
| 26 | + IDXD_DEV_IAX, |
| 27 | + IDXD_DEV_WQ, |
| 28 | + IDXD_DEV_GROUP, |
| 29 | + IDXD_DEV_ENGINE, |
| 30 | + IDXD_DEV_CDEV, |
| 31 | + IDXD_DEV_MAX_TYPE, |
| 32 | +}; |
| 33 | + |
| 34 | +struct idxd_dev { |
| 35 | + struct device conf_dev; |
| 36 | + enum idxd_dev_type type; |
| 37 | +}; |
22 | 38 |
|
23 | 39 | #define IDXD_REG_TIMEOUT 50 |
24 | 40 | #define IDXD_DRAIN_TIMEOUT 5000 |
@@ -52,7 +68,7 @@ struct idxd_irq_entry { |
52 | 68 | }; |
53 | 69 |
|
54 | 70 | struct idxd_group { |
55 | | - struct device conf_dev; |
| 71 | + struct idxd_dev idxd_dev; |
56 | 72 | struct idxd_device *idxd; |
57 | 73 | struct grpcfg grpcfg; |
58 | 74 | int id; |
@@ -111,7 +127,7 @@ enum idxd_wq_type { |
111 | 127 | struct idxd_cdev { |
112 | 128 | struct idxd_wq *wq; |
113 | 129 | struct cdev cdev; |
114 | | - struct device dev; |
| 130 | + struct idxd_dev idxd_dev; |
115 | 131 | int minor; |
116 | 132 | }; |
117 | 133 |
|
@@ -139,7 +155,7 @@ struct idxd_wq { |
139 | 155 | void __iomem *portal; |
140 | 156 | struct percpu_ref wq_active; |
141 | 157 | struct completion wq_dead; |
142 | | - struct device conf_dev; |
| 158 | + struct idxd_dev idxd_dev; |
143 | 159 | struct idxd_cdev *idxd_cdev; |
144 | 160 | struct wait_queue_head err_queue; |
145 | 161 | struct idxd_device *idxd; |
@@ -174,7 +190,7 @@ struct idxd_wq { |
174 | 190 | }; |
175 | 191 |
|
176 | 192 | struct idxd_engine { |
177 | | - struct device conf_dev; |
| 193 | + struct idxd_dev idxd_dev; |
178 | 194 | int id; |
179 | 195 | struct idxd_group *group; |
180 | 196 | struct idxd_device *idxd; |
@@ -218,7 +234,7 @@ struct idxd_driver_data { |
218 | 234 | }; |
219 | 235 |
|
220 | 236 | struct idxd_device { |
221 | | - struct device conf_dev; |
| 237 | + struct idxd_dev idxd_dev; |
222 | 238 | struct idxd_driver_data *data; |
223 | 239 | struct list_head list; |
224 | 240 | struct idxd_hw hw; |
@@ -301,8 +317,58 @@ enum idxd_completion_status { |
301 | 317 | IDXD_COMP_DESC_ABORT = 0xff, |
302 | 318 | }; |
303 | 319 |
|
304 | | -#define confdev_to_idxd(dev) container_of(dev, struct idxd_device, conf_dev) |
305 | | -#define confdev_to_wq(dev) container_of(dev, struct idxd_wq, conf_dev) |
| 320 | +#define idxd_confdev(idxd) &idxd->idxd_dev.conf_dev |
| 321 | +#define wq_confdev(wq) &wq->idxd_dev.conf_dev |
| 322 | +#define engine_confdev(engine) &engine->idxd_dev.conf_dev |
| 323 | +#define group_confdev(group) &group->idxd_dev.conf_dev |
| 324 | +#define cdev_dev(cdev) &cdev->idxd_dev.conf_dev |
| 325 | + |
| 326 | +#define confdev_to_idxd_dev(dev) container_of(dev, struct idxd_dev, conf_dev) |
| 327 | + |
| 328 | +static inline struct idxd_device *confdev_to_idxd(struct device *dev) |
| 329 | +{ |
| 330 | + struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); |
| 331 | + |
| 332 | + return container_of(idxd_dev, struct idxd_device, idxd_dev); |
| 333 | +} |
| 334 | + |
| 335 | +static inline struct idxd_wq *confdev_to_wq(struct device *dev) |
| 336 | +{ |
| 337 | + struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); |
| 338 | + |
| 339 | + return container_of(idxd_dev, struct idxd_wq, idxd_dev); |
| 340 | +} |
| 341 | + |
| 342 | +static inline struct idxd_engine *confdev_to_engine(struct device *dev) |
| 343 | +{ |
| 344 | + struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); |
| 345 | + |
| 346 | + return container_of(idxd_dev, struct idxd_engine, idxd_dev); |
| 347 | +} |
| 348 | + |
| 349 | +static inline struct idxd_group *confdev_to_group(struct device *dev) |
| 350 | +{ |
| 351 | + struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); |
| 352 | + |
| 353 | + return container_of(idxd_dev, struct idxd_group, idxd_dev); |
| 354 | +} |
| 355 | + |
| 356 | +static inline struct idxd_cdev *dev_to_cdev(struct device *dev) |
| 357 | +{ |
| 358 | + struct idxd_dev *idxd_dev = confdev_to_idxd_dev(dev); |
| 359 | + |
| 360 | + return container_of(idxd_dev, struct idxd_cdev, idxd_dev); |
| 361 | +} |
| 362 | + |
| 363 | +static inline void idxd_dev_set_type(struct idxd_dev *idev, int type) |
| 364 | +{ |
| 365 | + if (type >= IDXD_DEV_MAX_TYPE) { |
| 366 | + idev->type = IDXD_DEV_NONE; |
| 367 | + return; |
| 368 | + } |
| 369 | + |
| 370 | + idev->type = type; |
| 371 | +} |
306 | 372 |
|
307 | 373 | extern struct bus_type dsa_bus_type; |
308 | 374 | extern struct bus_type iax_bus_type; |
|
0 commit comments