mirror of
https://github.com/ipxe/ipxe
synced 2025-12-28 18:42:53 +03:00
[interface] Convert all job-control interfaces to generic interfaces
Remove job-control as an interface type, and replace job-control interfaces with generic interfaces supporting the close() method. (Both done() and kill() are absorbed into the function of close(); kill() is merely close(-ECANCELED).) Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -238,7 +238,7 @@ struct dhcp_session {
|
||||
/** Reference counter */
|
||||
struct refcnt refcnt;
|
||||
/** Job control interface */
|
||||
struct job_interface job;
|
||||
struct interface job;
|
||||
/** Data transfer interface */
|
||||
struct xfer_interface xfer;
|
||||
|
||||
@@ -294,16 +294,13 @@ static void dhcp_free ( struct refcnt *refcnt ) {
|
||||
*/
|
||||
static void dhcp_finished ( struct dhcp_session *dhcp, int rc ) {
|
||||
|
||||
/* Block futher incoming messages */
|
||||
job_nullify ( &dhcp->job );
|
||||
xfer_nullify ( &dhcp->xfer );
|
||||
|
||||
/* Stop retry timer */
|
||||
stop_timer ( &dhcp->timer );
|
||||
|
||||
/* Free resources and close interfaces */
|
||||
/* Shut down interfaces */
|
||||
xfer_nullify ( &dhcp->xfer );
|
||||
xfer_close ( &dhcp->xfer, rc );
|
||||
job_done ( &dhcp->job, rc );
|
||||
intf_shutdown ( &dhcp->job, rc );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1366,26 +1363,15 @@ static void dhcp_timer_expired ( struct retry_timer *timer, int fail ) {
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle kill() event received via job control interface
|
||||
*
|
||||
* @v job DHCP job control interface
|
||||
*/
|
||||
static void dhcp_job_kill ( struct job_interface *job ) {
|
||||
struct dhcp_session *dhcp =
|
||||
container_of ( job, struct dhcp_session, job );
|
||||
|
||||
/* Terminate DHCP session */
|
||||
dhcp_finished ( dhcp, -ECANCELED );
|
||||
}
|
||||
|
||||
/** DHCP job control interface operations */
|
||||
static struct job_interface_operations dhcp_job_operations = {
|
||||
.done = ignore_job_done,
|
||||
.kill = dhcp_job_kill,
|
||||
.progress = ignore_job_progress,
|
||||
static struct interface_operation dhcp_job_op[] = {
|
||||
INTF_OP ( intf_close, struct dhcp_session *, dhcp_finished ),
|
||||
};
|
||||
|
||||
/** DHCP job control interface descriptor */
|
||||
static struct interface_descriptor dhcp_job_desc =
|
||||
INTF_DESC ( struct dhcp_session, job, dhcp_job_op );
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Instantiators
|
||||
@@ -1424,7 +1410,7 @@ __weak void get_cached_dhcpack ( void ) {}
|
||||
* started; a positive return value indicates the success condition of
|
||||
* having fetched the appropriate data from cached information.
|
||||
*/
|
||||
int start_dhcp ( struct job_interface *job, struct net_device *netdev ) {
|
||||
int start_dhcp ( struct interface *job, struct net_device *netdev ) {
|
||||
struct dhcp_session *dhcp;
|
||||
int rc;
|
||||
|
||||
@@ -1440,7 +1426,7 @@ int start_dhcp ( struct job_interface *job, struct net_device *netdev ) {
|
||||
if ( ! dhcp )
|
||||
return -ENOMEM;
|
||||
ref_init ( &dhcp->refcnt, dhcp_free );
|
||||
job_init ( &dhcp->job, &dhcp_job_operations, &dhcp->refcnt );
|
||||
intf_init ( &dhcp->job, &dhcp_job_desc, &dhcp->refcnt );
|
||||
xfer_init ( &dhcp->xfer, &dhcp_xfer_operations, &dhcp->refcnt );
|
||||
timer_init ( &dhcp->timer, dhcp_timer_expired );
|
||||
dhcp->netdev = netdev_get ( netdev );
|
||||
@@ -1456,7 +1442,7 @@ int start_dhcp ( struct job_interface *job, struct net_device *netdev ) {
|
||||
dhcp_set_state ( dhcp, &dhcp_state_discover );
|
||||
|
||||
/* Attach parent interface, mortalise self, and return */
|
||||
job_plug_plug ( &dhcp->job, job );
|
||||
intf_plug_plug ( &dhcp->job, job );
|
||||
ref_put ( &dhcp->refcnt );
|
||||
return 0;
|
||||
|
||||
@@ -1517,7 +1503,7 @@ static void pxebs_list ( struct dhcp_session *dhcp, void *raw,
|
||||
* If successful, the Boot Server ACK will be registered as an option
|
||||
* source.
|
||||
*/
|
||||
int start_pxebs ( struct job_interface *job, struct net_device *netdev,
|
||||
int start_pxebs ( struct interface *job, struct net_device *netdev,
|
||||
unsigned int pxe_type ) {
|
||||
struct setting pxe_discovery_control_setting =
|
||||
{ .tag = DHCP_PXE_DISCOVERY_CONTROL };
|
||||
@@ -1543,7 +1529,7 @@ int start_pxebs ( struct job_interface *job, struct net_device *netdev,
|
||||
if ( ! dhcp )
|
||||
return -ENOMEM;
|
||||
ref_init ( &dhcp->refcnt, dhcp_free );
|
||||
job_init ( &dhcp->job, &dhcp_job_operations, &dhcp->refcnt );
|
||||
intf_init ( &dhcp->job, &dhcp_job_desc, &dhcp->refcnt );
|
||||
xfer_init ( &dhcp->xfer, &dhcp_xfer_operations, &dhcp->refcnt );
|
||||
timer_init ( &dhcp->timer, dhcp_timer_expired );
|
||||
dhcp->netdev = netdev_get ( netdev );
|
||||
@@ -1602,7 +1588,7 @@ int start_pxebs ( struct job_interface *job, struct net_device *netdev,
|
||||
dhcp_set_state ( dhcp, &dhcp_state_pxebs );
|
||||
|
||||
/* Attach parent interface, mortalise self, and return */
|
||||
job_plug_plug ( &dhcp->job, job );
|
||||
intf_plug_plug ( &dhcp->job, job );
|
||||
ref_put ( &dhcp->refcnt );
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user