astlpc.c (7c4509aac759dd14319e35c8c20b53dd822183d5) astlpc.c (ae59f4fe3a3ceaf52a682ada2a2b54855fad2408)
1/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2
3#if HAVE_CONFIG_H
4#include "config.h"
5#endif
6
7#if HAVE_ENDIAN_H
8#include <endian.h>

--- 923 unchanged lines hidden (view full) ---

932 if (body > (uint32_t)astlpc->binding.pkt_size) {
933 astlpc_prwarn(astlpc, "invalid RX len 0x%x", body);
934 return;
935 }
936
937 /* Eliminate the medium-specific header that we just read */
938 packet = astlpc->proto->packet_size(body) - 4;
939 pkt = mctp_pktbuf_alloc(&astlpc->binding, packet);
1/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2
3#if HAVE_CONFIG_H
4#include "config.h"
5#endif
6
7#if HAVE_ENDIAN_H
8#include <endian.h>

--- 923 unchanged lines hidden (view full) ---

932 if (body > (uint32_t)astlpc->binding.pkt_size) {
933 astlpc_prwarn(astlpc, "invalid RX len 0x%x", body);
934 return;
935 }
936
937 /* Eliminate the medium-specific header that we just read */
938 packet = astlpc->proto->packet_size(body) - 4;
939 pkt = mctp_pktbuf_alloc(&astlpc->binding, packet);
940 if (!pkt)
941 goto out_complete;
940 if (!pkt) {
941 astlpc_prwarn(astlpc, "unable to allocate pktbuf len 0x%x", packet);
942 return;
943 }
942
943 /*
944 * Read payload and medium-specific trailer from immediately after the
945 * medium-specific header.
946 */
947 mctp_astlpc_lpc_read(astlpc, mctp_pktbuf_hdr(pkt),
948 astlpc->layout.rx.offset + 4, packet);
949
944
945 /*
946 * Read payload and medium-specific trailer from immediately after the
947 * medium-specific header.
948 */
949 mctp_astlpc_lpc_read(astlpc, mctp_pktbuf_hdr(pkt),
950 astlpc->layout.rx.offset + 4, packet);
951
952 /* Inform the other side of the MCTP interface that we have read
953 * the packet off the bus before handling the contents of the packet.
954 */
955 mctp_astlpc_kcs_send(astlpc, 0x2);
956
950 /*
951 * v3 will validate the CRC32 in the medium-specific trailer and adjust
952 * the packet size accordingly. On older protocols validation is a no-op
953 * that always returns true.
954 */
955 if (astlpc->proto->pktbuf_validate(pkt)) {
956 mctp_bus_rx(&astlpc->binding, pkt);
957 } else {
958 /* TODO: Drop any associated assembly */
959 mctp_pktbuf_free(pkt);
960 astlpc_prdebug(astlpc, "Dropped corrupt packet");
961 }
957 /*
958 * v3 will validate the CRC32 in the medium-specific trailer and adjust
959 * the packet size accordingly. On older protocols validation is a no-op
960 * that always returns true.
961 */
962 if (astlpc->proto->pktbuf_validate(pkt)) {
963 mctp_bus_rx(&astlpc->binding, pkt);
964 } else {
965 /* TODO: Drop any associated assembly */
966 mctp_pktbuf_free(pkt);
967 astlpc_prdebug(astlpc, "Dropped corrupt packet");
968 }
962
963out_complete:
964 mctp_astlpc_kcs_send(astlpc, 0x2);
965}
966
967static void mctp_astlpc_tx_complete(struct mctp_binding_astlpc *astlpc)
968{
969 mctp_binding_set_tx_enabled(&astlpc->binding, true);
970}
971
972static int mctp_astlpc_finalise_channel(struct mctp_binding_astlpc *astlpc)

--- 354 unchanged lines hidden ---
969}
970
971static void mctp_astlpc_tx_complete(struct mctp_binding_astlpc *astlpc)
972{
973 mctp_binding_set_tx_enabled(&astlpc->binding, true);
974}
975
976static int mctp_astlpc_finalise_channel(struct mctp_binding_astlpc *astlpc)

--- 354 unchanged lines hidden ---