ncsi-rsp.c (2612e3bbc0386368a850140a6c9b990cd496a5ec) | ncsi-rsp.c (1c83c7089dea47b7b900001bc2f9da361cb40e4c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright Gavin Shan, IBM Corporation 2016. 4 */ 5 6#include <linux/module.h> 7#include <linux/kernel.h> 8#include <linux/init.h> --- 5 unchanged lines hidden (view full) --- 14#include <net/net_namespace.h> 15#include <net/sock.h> 16#include <net/genetlink.h> 17 18#include "internal.h" 19#include "ncsi-pkt.h" 20#include "ncsi-netlink.h" 21 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright Gavin Shan, IBM Corporation 2016. 4 */ 5 6#include <linux/module.h> 7#include <linux/kernel.h> 8#include <linux/init.h> --- 5 unchanged lines hidden (view full) --- 14#include <net/net_namespace.h> 15#include <net/sock.h> 16#include <net/genetlink.h> 17 18#include "internal.h" 19#include "ncsi-pkt.h" 20#include "ncsi-netlink.h" 21 |
22/* Nibbles within [0xA, 0xF] add zero "0" to the returned value. 23 * Optional fields (encoded as 0xFF) will default to zero. 24 */ 25static u8 decode_bcd_u8(u8 x) 26{ 27 int lo = x & 0xF; 28 int hi = x >> 4; 29 30 lo = lo < 0xA ? lo : 0; 31 hi = hi < 0xA ? hi : 0; 32 return lo + hi * 10; 33} 34 |
|
22static int ncsi_validate_rsp_pkt(struct ncsi_request *nr, 23 unsigned short payload) 24{ 25 struct ncsi_rsp_pkt_hdr *h; 26 u32 checksum; 27 __be32 *pchecksum; 28 29 /* Check NCSI packet header. We don't need validate --- 720 unchanged lines hidden (view full) --- 750 751 /* Find the channel */ 752 rsp = (struct ncsi_rsp_gvi_pkt *)skb_network_header(nr->rsp); 753 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, 754 NULL, &nc); 755 if (!nc) 756 return -ENODEV; 757 | 35static int ncsi_validate_rsp_pkt(struct ncsi_request *nr, 36 unsigned short payload) 37{ 38 struct ncsi_rsp_pkt_hdr *h; 39 u32 checksum; 40 __be32 *pchecksum; 41 42 /* Check NCSI packet header. We don't need validate --- 720 unchanged lines hidden (view full) --- 763 764 /* Find the channel */ 765 rsp = (struct ncsi_rsp_gvi_pkt *)skb_network_header(nr->rsp); 766 ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, 767 NULL, &nc); 768 if (!nc) 769 return -ENODEV; 770 |
758 /* Update to channel's version info */ | 771 /* Update channel's version info 772 * 773 * Major, minor, and update fields are supposed to be 774 * unsigned integers encoded as packed BCD. 775 * 776 * Alpha1 and alpha2 are ISO/IEC 8859-1 characters. 777 */ |
759 ncv = &nc->version; | 778 ncv = &nc->version; |
760 ncv->version = ntohl(rsp->ncsi_version); | 779 ncv->major = decode_bcd_u8(rsp->major); 780 ncv->minor = decode_bcd_u8(rsp->minor); 781 ncv->update = decode_bcd_u8(rsp->update); 782 ncv->alpha1 = rsp->alpha1; |
761 ncv->alpha2 = rsp->alpha2; 762 memcpy(ncv->fw_name, rsp->fw_name, 12); 763 ncv->fw_version = ntohl(rsp->fw_version); 764 for (i = 0; i < ARRAY_SIZE(ncv->pci_ids); i++) 765 ncv->pci_ids[i] = ntohs(rsp->pci_ids[i]); 766 ncv->mf_id = ntohl(rsp->mf_id); 767 768 return 0; --- 442 unchanged lines hidden --- | 783 ncv->alpha2 = rsp->alpha2; 784 memcpy(ncv->fw_name, rsp->fw_name, 12); 785 ncv->fw_version = ntohl(rsp->fw_version); 786 for (i = 0; i < ARRAY_SIZE(ncv->pci_ids); i++) 787 ncv->pci_ids[i] = ntohs(rsp->pci_ids[i]); 788 ncv->mf_id = ntohl(rsp->mf_id); 789 790 return 0; --- 442 unchanged lines hidden --- |