Signed-off-by: Kusakabe Si <linux@kskb.eu.org>
Change-Id: Ib1761e3b93dae70680646ce7fdd78a1168fd0b9f
// Interrupt
intCh chan uint8 // memif-global interrupt channel (value = queue ID)
// Interrupt
intCh chan uint8 // memif-global interrupt channel (value = queue ID)
+ intErrCh chan error // triggered when interrupt error occurs
queueIntCh []chan struct{} // per RX queue interrupt channel
// Rx/Tx queues
queueIntCh []chan struct{} // per RX queue interrupt channel
// Rx/Tx queues
// Initialize memif-global interrupt channel.
memif.intCh = make(chan uint8, 1<<6)
// Initialize memif-global interrupt channel.
memif.intCh = make(chan uint8, 1<<6)
+ memif.intErrCh = make(chan error, 1<<6)
// Initialize event file descriptor for stopping Rx/Tx queue polling.
memif.stopQPollFd = int(C.eventfd(0, C.EFD_NONBLOCK))
// Initialize event file descriptor for stopping Rx/Tx queue polling.
memif.stopQPollFd = int(C.eventfd(0, C.EFD_NONBLOCK))
+// GetInterruptErrorChan returns an Error channel
+// which fires if there are errors occurred while read data.
+func (memif *Memif) GetInterruptErrorChan() (ch <-chan error /* The error */) {
+ return memif.intErrCh
+}
+
// GetQueueInterruptChan returns an empty-data channel which fires every time
// there are data to read on a given queue.
// It is only valid to call this function if memif is in the connected state.
// GetQueueInterruptChan returns an empty-data channel which fires every time
// there are data to read on a given queue.
// It is only valid to call this function if memif is in the connected state.
if err != nil {
// Close memif-global interrupt channel.
close(memif.intCh)
if err != nil {
// Close memif-global interrupt channel.
close(memif.intCh)
// Close file descriptor stopQPollFd.
C.close(C.int(memif.stopQPollFd))
}
// Close file descriptor stopQPollFd.
C.close(C.int(memif.stopQPollFd))
}
continue
}
log.WithField("err", err).Error("epoll_wait() failed")
continue
}
log.WithField("err", err).Error("epoll_wait() failed")
// Wait until an interrupt signal is received.
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)
// Wait until an interrupt signal is received.
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt)
+ var intErrch = memif.GetInterruptErrorChan()
+ select {
+ case err = <-intErrch:
+ fmt.Printf("Exit due to interface error: %v\n", err)
+ return
+ case <-sigChan:
+ fmt.Printf("Exit by os.Interrupt")
+ return
+ }