コード例 #1
0
/*
 * TransmitCredit assembles a control credit packet and initializes the transmit procedure
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * channel is the channel the credit should be applied to
 * bytecredit is the amount the byte credit should be increased
 * sendcredit is the amount the send credit should be increased
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitCredit (int8 acktype, int8 channel, int32 bytecredit, int32 sendcredit, MUX* mux)
{
    COMMBUFF*      commbuff;
    CREDIT_PACKET* packetdata;

    DEBUG(
        "TransmitCredit(%lu, %lu, %lu, 0x%lu, %p)\n",
        (int32)acktype,
        (int32)channel,
        (int32)bytecredit,
        (int32)sendcredit,
        mux
    );

    commbuff = int_alloc_commbuff(sizeof(CREDIT_PACKET));

    convert_dword(bytecredit);
    convert_dword(sendcredit);

    packetdata       = (CREDIT_PACKET*)commbuff_data(commbuff);
    packetdata->type = PACKETTYPE_CREDIT;

    commbuff_copyin_byte(commbuff, offsetof(CREDIT_PACKET, acktype), acktype);
    commbuff_copyin_byte(commbuff, offsetof(CREDIT_PACKET, channel), channel);
    commbuff_copyin_dword(commbuff, offsetof(CREDIT_PACKET, bytecredit), bytecredit);
    commbuff_copyin_dword(commbuff, offsetof(CREDIT_PACKET, sendcredit), sendcredit);

    queue_commbuff(commbuff, &mux->send_queue);

    mux->total_queued_amount += sizeof(CREDIT_PACKET);

    task_schedule(&mux->send_task);

    return DEBUGERROR(ERROR_NONE);
}
コード例 #2
0
ファイル: protocol.c プロジェクト: MuMu360121/jordan-kernel
/*
 * TransmitEnableChannel assembles a control enable channel packet and
 * initializes the transmit procedure
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * channel is the channel to be enabled
 * host_interface is the interface which belongs to the host and
 * 	is requesting the enable
 * client_interface is the interface which belongs to the client and
 * 	is responding to the enable
 * bytecredit is the size of the receive buffer on the senders side
 * sendcredit is the number of sends available to the senders side
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitEnableChannel(int8 acktype,
			    int8 channel,
			    int8 host_interface,
			    int8 client_interface,
			    int32 bytecredit, int32 sendcredit, MUX *mux)
{
	COMMBUFF *commbuff;
	ENABLECHANNEL_PACKET *packetdata;

	DEBUG("TransmitEnableChannel(%lu, %lu, %lu, %lu, %lu, %lu, %p)\n",
	      (int32) acktype,
	      (int32) channel,
	      (int32) host_interface,
	      (int32) client_interface,
	      (int32) bytecredit, (int32) sendcredit, mux);

	commbuff = int_alloc_commbuff(sizeof(ENABLECHANNEL_PACKET));

	convert_dword(bytecredit);
	convert_dword(sendcredit);

	packetdata = (ENABLECHANNEL_PACKET *) commbuff_data(commbuff);
	packetdata->type = PACKETTYPE_ENABLECHANNEL;

	commbuff_copyin_byte(commbuff,
			     offsetof(ENABLECHANNEL_PACKET, acktype),
			     acktype);
	commbuff_copyin_byte(commbuff,
			     offsetof(ENABLECHANNEL_PACKET, channel),
			     channel);
	commbuff_copyin_byte(commbuff,
			     offsetof(ENABLECHANNEL_PACKET,
				      host_interface), host_interface);
	commbuff_copyin_byte(commbuff,
			     offsetof(ENABLECHANNEL_PACKET,
				      client_interface), client_interface);
	commbuff_copyin_dword(commbuff,
			      offsetof(ENABLECHANNEL_PACKET, bytecredit),
			      bytecredit);
	commbuff_copyin_dword(commbuff,
			      offsetof(ENABLECHANNEL_PACKET, sendcredit),
			      sendcredit);

	queue_commbuff(commbuff, &mux->send_queue);

	mux->total_queued_amount += sizeof(ENABLECHANNEL_PACKET);

	task_schedule(&mux->send_task);

	return DEBUGERROR(ERROR_NONE);
}