From 5b4d0ab9a70278ab3e696f70d68a4ad0e87ce711 Mon Sep 17 00:00:00 2001 From: Evan Lojewski Date: Sat, 4 Jul 2020 19:43:20 -0600 Subject: ncsi: Don't report an error when clearing the initial state of nonexistent channels. (#83) The NCSI specification implies that when a channel does not exist, no response is given. This behavior is consistent with the proprietary firmware. When a response is given, the linux kernel spews (~30 times) "NCSI: 'bad' packet ignored for type 0x80" on an invalid response. Disable the response to silence these messages and make the behavior match the proprietary firmware. --- libs/NCSI/ncsi.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'libs') diff --git a/libs/NCSI/ncsi.c b/libs/NCSI/ncsi.c index 9981102..91197a4 100644 --- a/libs/NCSI/ncsi.c +++ b/libs/NCSI/ncsi.c @@ -285,11 +285,15 @@ static void clearInitialStateHandler(NetworkFrame_t *frame) { int ch = frame->controlPacket.ChannelID & CHANNEL_ID_MASK; - gPackageState.port[ch]->shm_channel->NcsiChannelInfo.bits.Ready = true; - debug("Clear initial state: channel %x\n", ch); + // Only send a response if this channel exists. + if (ch < NUM_CHANNELS) + { + gPackageState.port[ch]->shm_channel->NcsiChannelInfo.bits.Ready = true; + debug("Clear initial state: channel %x\n", ch); - sendNCSIResponse(frame->controlPacket.InstanceID, frame->controlPacket.ChannelID, frame->controlPacket.ControlPacketType, - NCSI_RESPONSE_CODE_COMMAND_COMPLETE, NCSI_REASON_CODE_NONE); + sendNCSIResponse(frame->controlPacket.InstanceID, frame->controlPacket.ChannelID, frame->controlPacket.ControlPacketType, + NCSI_RESPONSE_CODE_COMMAND_COMPLETE, NCSI_REASON_CODE_NONE); + } } static void selectPackageHandler(NetworkFrame_t *frame) @@ -617,7 +621,7 @@ void handleNCSIFrame(NetworkFrame_t *frame) NCSI_RESPONSE_CODE_COMMAND_FAILED, NCSI_REASON_CODE_INVALID_PAYLOAD_LENGTH); } else if ((handler->packageCommand && ch == CHANNEL_ID_PACKAGE) || // Package commands are always accepted. - (handler->ignoreInit && ch < NUM_CHANNELS)) + (handler->ignoreInit)) { // Package command. Must handle. debug("[%x] packageCommand/ignore init channel: %d\n", command, ch); -- cgit v1.2.1