numam-dpdk/lib/librte_eal/common/hotplug_mp.h
Qi Zhang 244d513071 eal: enable hotplug on multi-process
We are going to introduce the solution to handle hotplug in
multi-process, it includes the below scenario:

1. Attach a device from the primary
2. Detach a device from the primary
3. Attach a device from a secondary
4. Detach a device from a secondary

In the primary-secondary process model, we assume devices are shared
by default. that means attaches or detaches a device on any process
will broadcast to all other processes through mp channel then device
information will be synchronized on all processes.

Any failure during attaching/detaching process will cause inconsistent
status between processes, so proper rollback action should be considered.

This patch covers the implementation of case 1,2.
Case 3,4 will be implemented on a separate patch.

IPC scenario for Case 1, 2:

attach a device
a) primary attach the new device if failed goto h).
b) primary send attach sync request to all secondary.
c) secondary receive request and attach the device and send a reply.
d) primary check the reply if all success goes to i).
e) primary send attach rollback sync request to all secondary.
f) secondary receive the request and detach the device and send a reply.
g) primary receive the reply and detach device as rollback action.
h) attach fail
i) attach success

detach a device
a) primary send detach sync request to all secondary
b) secondary detach the device and send reply
c) primary check the reply if all success goes to f).
d) primary send detach rollback sync request to all secondary.
e) secondary receive the request and attach back device. goto g)
f) primary detach the device if success goto g), else goto d)
g) detach fail.
h) detach success.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
2018-10-17 10:16:18 +02:00

47 lines
1.2 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2018 Intel Corporation
*/
#ifndef _HOTPLUG_MP_H_
#define _HOTPLUG_MP_H_
#include "rte_dev.h"
#include "rte_bus.h"
#define EAL_DEV_MP_ACTION_REQUEST "eal_dev_mp_request"
#define EAL_DEV_MP_ACTION_RESPONSE "eal_dev_mp_response"
#define EAL_DEV_MP_DEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
#define EAL_DEV_MP_BUS_NAME_MAX_LEN 32
#define EAL_DEV_MP_DEV_ARGS_MAX_LEN 128
enum eal_dev_req_type {
EAL_DEV_REQ_TYPE_ATTACH,
EAL_DEV_REQ_TYPE_DETACH,
EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK,
EAL_DEV_REQ_TYPE_DETACH_ROLLBACK,
};
struct eal_dev_mp_req {
enum eal_dev_req_type t;
char devargs[EAL_DEV_MP_DEV_ARGS_MAX_LEN];
int result;
};
/**
* This is a synchronous wrapper for secondary process send
* request to primary process, this is invoked when an attach
* or detach request is issued from primary process.
*/
int eal_dev_hotplug_request_to_primary(struct eal_dev_mp_req *req);
/**
* this is a synchronous wrapper for primary process send
* request to secondary process, this is invoked when an attach
* or detach request issued from secondary process.
*/
int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req);
#endif /* _HOTPLUG_MP_H_ */